Getting Ajax Filtering (Categories, Labels, Etc) to work for custom queries/pages

4.21K viewsIssues
0

First off; Thank you for the amazing plugin @rahularyan. I’m currently integrating Anspress into a BuddyPress community and been diving into creating custom queries showing Q&A’s in a specific category/tag. I got a basic loop working using the code below, but the AJAX filtering does not work. It seems some query parameters are being added to page URL and I’m not sure what the logic is here. Is there any way to make this work?

      <?php
      global $questions;
      $group_slug = bp_get_group_slug();
      $questions 		 = new Question_Query( array(
        'post_type'  => 'question',
      	'tax_query' => array(
      		array(
      			'taxonomy' => 'question_tag',
      			'field'    => 'slug',
      			'terms'    => 'support'
      		)
      	)

      )
      );
  		echo '<div id="anspress">';
  	    ap_get_template_part( 'buddypress/user-questions' );
  	    echo '</div>';
  	    wp_reset_postdata();
       ?>

Thanks again for the amazing plugin, it’s a joy to play around with!

0

I don’t think there is anything wrong in you code. BTW you do not need post_type args as question_query will fetch only question cpt.

I added the CPT parameter a to see if it would make a difference when using the AJAX filter.
I’ll disable all the Anspress extension plugins and see if that makes a difference 🙂