Adding Search & Filter to custom WP_Query?
I’m using Search & Filter Pro, and want to add it to my currently setup WP_Query:
if( get_sub_field('type_of_post') == 'age' ) {
$post_type = 'courses';
$taxonomy = 'ages';
$term = get_sub_field( "age_category_posts" );
$orderby = 'meta_value_num';
$order = 'ASC';
$meta_key = 'courses_order';
$the_tax_query = $the_query;
$post_per_page = '100000000';
} else { }
$the_query = new WP_Query( array(
'posts_per_page'=> $post_per_page,
'post_type'=> $post_type,
'orderby' => $orderby,
'order' => $order,
'paged' => $paged,
'meta_key' => $meta_key,
‘search_filter_id’ => '1835',
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'term_id',
'terms' => $term,
)
),
'paged' => get_query_var('paged') ? get_query_var('paged') : 1)
);
I’ve then added the following shortcode:
<?php echo do_shortcode( '[searchandfilter id="1835"]' ); ?>
The form appears, ajax is turned on, but it just doesn’t seem to work.
Am I better of custom coding a search filtering system like this, or using this plugin? I want it to work as follows:
On a page for 15 year olds, courses show as below in WP Query by selecting ’15’ in ‘ages’ taxonomy within ACF. I then want to be able to filter through the courses assigned the taxonomy 15 based on another taxonomy assigned to that custom post type ‘subject’.
Thanks,
Meg
Leave an answer
You must login or register to add a new answer .