Ask automatic for each category?

6.09K viewsGeneral
0

I am planning on having a lot of categories, when on the ask page it has a huge list to choose the category.

Is there a way to integrate the Ask on the current page (current category) rather than moving away from the page?

Answered question
0

Hi Rahul:
Thanks for your reply.
The error still exist. This is the full code:

div class="ap-list-head clearfix">
 <div class="pull-right">
  global $question_category;
  $ask_url = ap_get_link_to( 'ask' );
  if( !empty( $question_category->term_id ) ) {
       $ask_url = $ask_url . '?form_question[category]=' . $question_category->term_id;
  }
   echo '<a class="ap-btn-ask" href="' . $ask_url . '">' 
         . __( 'Ask question', 'anspress-question-answer' ) 
         . '</a>';
 </div>

Posted new comment

Thanks Rahul.
I tried to add this code to functions.php in my child theme.
No luck, any other idea?

0

Hi Rahul:
I tried the code you posted. The did not work correctly.
Please see attached screenshot for the error.

Thanks,

Posted new comment

This solution was for an older version. Please replace ?category with ?form_question[category]

0

Please override list-head.php and replace

<?php ap_ask_btn(); ?>

to this:

global $question_category;
$ask_url = ap_get_link_to( 'ask' );
if( !empty( $question_category->term_id ) ) {
    $ask_url = $ask_url . '?category=' . $question_category->term_id;
}

echo '<a class="ap-btn-ask" href="' . $ask_url . '">' 
       . __( 'Ask question', 'anspress-question-answer' ) 
       . '</a>';

Cheers.