Hi,

As Rahul has already posted a FAQ about the same –

https://anspress.io/resources/faq/insertimport-questions-programmatically/

But it has some open issues, which I have already asked in another question. Here, I am writing my work around using the same FAQ to import/insert questions/answers programmatically.

 

Inserting/importing question is quite easy, as the core function is already been adapted for it. So it’s pretty much same as mentioned in FAQ. Only additional thing I did was to insert/update qameta and activity on asking new question.

However inserting/importing answer gave me a headache, as its core function require some modifications, to use it out of the box. Some of the code blocks from function submit_answer_form, which is causing issue are –

`$question_id = ap_sanitize_unslash( ‘question_id’, ‘r’ );`

`$form->save_values_session( $question_id );`

`if ( $form->have_errors() ) {…}`

 

So I created a new custom function in my child theme, which is nothing but the same as submit_answer_form but tweaked it as per my use (in short, I provided parent_id for the answer in the function args).

I can’t seem to be able to embed gist code here (maybe anyone with access can edit this post and embed it), following is the link of function which one should add in his child theme’s functions.php

https://gist.github.com/atultiwari/53471873ac622b2cf039efebf897c2b5

 

Following is the link for function, which can be used/modified for inserting/importing question/answer programmatically (please note that, for my usage I needed multiple tags, so I created an array for it named `$anspress_tags_id` in the function)-

https://gist.github.com/atultiwari/29ddff5fa59c97153061d3068db1531f

 

P.S. – I used latest master build (dated 18-12-2017) for it and I am no programmer, just reverse programmed (sort of) the codes which was already posted by Rahul.

@Rahul, please have a look at it in your free time and provide suggestion, how can I improve it?

 

Thanks

Regards,

Dr. Atul

I’m facing this issue from past 1-2 weeks tried a lot but couldn’t fix it. Please Help

When Autoptimize’s Optimize JavaScript Code? is checked, the Ask page may fail to load the i18n texts for the AnsPress TinyMCE buttons: Insert image and Insert code.

Workaround:

Using Autoptimize Options, exclude js/tinymce/plugins/compat3x/plugin.min.js from Autoptimize

On Autoptimize, when Optimize JavaScript Code? is checked, AnsPress’ Ask page may fail to load TinyMCE.

 

Workaround:

Using Autoptimize Options, exclude js/tinymce/tinymce.min.js from Autoptimize.

iam trying to install Styles plugin to easy manage the colors of menus and Texts on the firebug theme but its doesn’t  show under apparence / Cutomize

 

Styles

 

How to solve that ?

When a website visitor is using “Search” for searching all questions, rather than displaying the results from their specific search the content below is just the list of all results.

Also, I see that Ans 4.1.5 is out, but WP repository doesn’t show that it isn’t available?

i cant edit submitted answer. already tried using 2 account. a participant or an administrator, still error.

 

Hi – I’ve seen some posts concerning myCRED and tried some functions around ap_reputation, but cannot seem to get these to work. Points appear to be awarded when opening a question, but not when any comments are added.

Any ideas ?

Thanks

I’d like to add category to my single question permalinks

I have the page setup correctly with the shortcode and everything, but the page is completely empty. The top users widget is empty as well…

Is there something I have to do to a user’s profile for them to be displayed?