Shivankit1091
asked 6 years ago

I want to add auto-suggest capability with the ‘Question-tags’ field on the “Ask-a-question” page. 
I know you guys maintain a Question Tags database and this functionality is possible. Can you help me with this?

4 Answers
DominicStaff
answered 6 years ago

You can open the question-submit-form.php file and find the line 58 to 60 then replace it with the following code: 

<label for="question-tag"><?php _e( 'Tag', 'dwqa' ) ?></label>
      <?php
          $exclude_tags = get_term_by( 'name', 'FAQ', 'dwqa-question_tag' );
          $exclude_tags_id = array();
          if( ! empty($exclude_tags) ) {
              $exclude_tags_id[] = $exclude_tags->term_id;
          }

          wp_dropdown_categories( array(
              'name'          => 'question-tag',
              'id'            => 'question-tag',
              'taxonomy'      => 'dwqa-question_tag',
              'hide_empty'    => 0,
       'selected'      => isset( $_POST['question-tag'] ) ? esc_attr( $_POST['question-tag'] ) : false, 
               'quicktags'     => array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ),                 'class'         => 'input-block-level',
               'exclude'       => $exclude_tags_id
           ) );
     ?>
Shivankit1091
replied 5 years ago

Instead of having a drop-down field (wp_dropdown_categories) can we just a simple textbox?

Shivankit1091
answered 5 years ago

Thanks, Dominic! 
This is great. We are looking to improve this as well. 
Please see the image below for end-functionality we are trying to achieve.

 

Shivankit1091
answered 5 years ago

Here is another scenario :
 
 
 

Shivankit1091
answered 5 years ago

And here is another scenario. This is the functionality we are trying to achieve. Can you help me?
 
 
 

Dominic Staff
replied 5 years ago

<p><p>I have checked your screenshot and see that this is a good idea.  But the plugin does not support to custom the tag box as you wish. You can use the Select2 js plugin. URL: https://select2.org/</p>

Shivankit1091
replied 5 years ago

Hi Dominic,

I’ve added the Dynamic Option Creation (Select2.js) plugin for this functionality. There are a couple of problems that I’m facing while integrating Select2.js with DWQA –

1. I can’t post multiple options with a question.
2. The new option added isn’t saved for future use in the DWQA Tags table.

Can you please help me with this functionality. We’d like to get some custom work done and collaborate with you guys.

Dominic Staff
replied 5 years ago

If you still face their issue, you can send me all the request, we will discuss about it.

Powered by DW Question & Answer Pro