Forums › Forums › Search & Filter Pro › Can't get results to filter
- This topic has 15 replies, 2 voices, and was last updated 6 years, 8 months ago by Trevor.
-
Anonymous(Private) March 15, 2018 at 7:30 pm #166306
Hi there
I wonder if you can help at all? This is the page I am having issues with: http://dd-server.co.uk/vinetrail/producers/
The custom post type (Producers) that is being filtered has two taxonomies – Country and Region. I want to filter using AJAX by Country only but I need the results to be grouped by Region, as currently shown via the collapsible divs.
Currently when I check the box for Spain, it looks like it’s loading the results but all posts are still shown and no filtering is actually taking place.
I am using a custom template with a WP_Query and have added the search filter ID but not entirely sure I have done this correctly.
Anonymous(Private) March 16, 2018 at 1:41 pm #166422This is my query, does this help?
$producers_query = new WP_Query( array(
‘post_type’ => ‘producers’,
‘orderby’ => ‘title’,
‘order’ => ‘ASC’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘producer_region’,
‘field’ => ‘slug’,
‘terms’ => array( $region_group_term->slug ),
‘operator’ => ‘IN’
)
),
‘search_filter_id’ => 788
) );Anonymous(Private) March 16, 2018 at 2:01 pm #166431Oops! I thought because it was AJAX and loading on the same page that it didn’t need a URL. Now it works! Thank you!
I do have a couple more queries, (sorry to be a pain). Now it is working, it still shows all of the taxonomy terms rather than just showing the ones relevant to the search results, it there a way to only show the taxonomy terms that have filtered results in?
Also, at the top of the page, just above the search form I need it to show the current filter that is active and be able to clear the filters by clicking on CLEAR ALL – I did have a look through the forums so I believe this is possible, but I didn’t really understand now to implement this.
Anonymous(Private) March 16, 2018 at 2:06 pm #166436By the way, I have set the URL to http://dd-server.co.uk/vinetrail/producers but it says the shortcode must be included, where would I put that?
Trevor(Private) March 16, 2018 at 2:12 pm #166438If you are setting the collapsible div functionality you need to reset it when Ajax triggers, like this (put your code instead of the comment):
<script>(function ( $ ) { "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); // load your div code here }); }(jQuery));</script>
If you have the Custom display results method, I am not sure what that error message is. Can you screenshot it, upload it to an image sharing site, and give me the link?
-
AuthorPosts