Forums › Forums › Search & Filter Pro › Ignoring filter for one result shortcode
- This topic has 4 replies, 2 voices, and was last updated 7 years, 5 months ago by Trevor.
-
Anonymous(Private) July 16, 2017 at 9:27 pm #120880
We have a restaurant guide where users can filter restaurants by cuisine and price point:
We’re returning results via shortcode and a custom template. It works great!
We have a second S&F filter returning results in the sidebar. These are intended to be Featured restaurants in the user’s price point. For this “search form” (it’s actually just the results shortcode) I limited the results to the ID of a category called featured. So far so good.
The only thing I wish I could change about this set up is that users are selecting cuisine and price point (and I don’t really want to limit the sidebar results by cuisine). I tried using the settings on the Tags, Categories, and Taxonomies tab to include all the cuisines, but it looks like this only includes possible results not actual results.
Is there anyway to ignore the URL filter for the shortcode in the sidebar. My concern is that in being so specific: “cuisine and price point and featured” I’ll end up with a lot of empty results in the sidebar.
Thank you!
Trevor(Private) July 17, 2017 at 8:01 am #120893Hi David, Your license for support and upgrades is expired, but I will point you in the direction I think you will need to go. Here:
For the sidebar search you would need to remove all the extraneous filter settings and return the shortened arguments. I am not sure how, or if, that would work.
Anonymous(Private) July 22, 2017 at 6:07 pm #122190Hi Trevor,
We renewed our license. Thanks for the reminder!
I’m trying to walk through the doc you shared and having a little trouble. Essentially, I just want to say that for Search Form 2051 the Category should always be All Items. Even when a user has selected a category that is being used with the other Search result filter on the page.
Here’s the code from the doc with the appropriate Search Form ID:
function filter_function_name( $query_args, $sfid ) { //if search form ID = 2051, the do something with this query if($sfid==2051) { //modify $query_args here before returning it } return $query_args; } add_filter( 'sf_edit_query_args', 'filter_function_name', 20, 2 );
I’ve tried to figure out the syntax for saying Category == All without luck.
Would appreciate your help.
Thanks!
Trevor(Private) July 24, 2017 at 8:17 am #122346The first thing to do is to be able to print to your page the current query (which is an array), and do a few searches to see what the data looks like, when the category is set, and when it is set to ALL. You would do this using the PHP print_r function, so a quick search for snippets on this forum later …
See if this prints your query out:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(2051)->current_query()->get_array(); echo '<pre>',print_r($sf_current_query),'</pre>'; ?>
-
AuthorPosts