Is it possible to add tags for answers?

6.06K viewsUpdates
0

Hi, Rahul.

 

We wonder whether it is possible to apply tags feature on answers like questions.

If possible, please give us directions.

 

Thanks

1

@jmoon: have a look at the wp-content/plugins/tags-for-anspress/tags-for-anspress.php file.

In there you’ll finde the following hooks:

add_action('ap_ask_form_fields', array($this, 'ask_from_tag_field'), 10, 2);
add_action('ap_ask_fields_validation', array($this, 'ap_ask_fields_validation'));
add_action( 'ap_processed_new_question', array($this, 'after_new_question'), 0, 2 );
add_action( 'ap_processed_update_question', array($this, 'after_new_question'), 0, 2 );

Simply copy & paste those and the corresponding functions. To make a clear separation between questions & answers, make sure you also copy & rename the function names. I’ve done it like the following:

add_action('ap_answer_form_fields', array($this, 'answer_form_tag_field'), 10, 2);
add_action('ap_answer_fields_validation', array($this, 'ap_answer_fields_validation'));
add_action( 'ap_processed_new_answer', array($this, 'after_new_answer'), 0, 2 );
add_action( 'ap_processed_update_answer', array($this, 'after_new_answer'), 0, 2 );

Also, If you would like to make selecting tags optional you have to remove the ap_ask_fields_validation or the ap_answer_fields_validation hooks.

@Rahul, I just noticed, (from above code snippet) you have written “ask_from_tag_field” in the first line instead of “ask_FORM….”. Is it typo or intentional?

You are viewing 1 out of 3 answers, click here to view all answers.