Forums Forums Search & Filter Pro Ignoring filter for one result shortcode

Viewing 5 posts - 1 through 5 (of 5 total)
  • Anonymous
    #120880

    We have a restaurant guide where users can filter restaurants by cuisine and price point:

    http://restaurantsdev.charlottesville.guide/search-results/?_sft_category=american-food&_sft_post_tag=mid-range

    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
    #120893

    Hi 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:

    https://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/#Edit_Query_Arguments

    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
    #121112

    Thanks Trevor, I’ll take a look at this doc, and I’ll get our license renewed. Your tool has been perfect for our site! Really appreciate it. Good work!

    Anonymous
    #122190

    Hi 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
    #122346

    The 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>';
    ?>
Viewing 5 posts - 1 through 5 (of 5 total)