Custom Filter Applied to Initial Search Results

Forums › Forums › Search & Filter Pro › Custom Filter Applied to Initial Search Results

Viewing 4 posts – 1 through 4 (of 4 total)
  • Anonymous
    #120629

    I have a site that is for 3 different users, and I have landing pages for each user. For example, Consultants: “http://dev-edible-alpha.pantheonsite.io/explore/consultants/. Each user has content that is curated for them via a category – in the case of consultants, the category is “for consultants.” My search results are being displayed as an archive.

    The standard search page works great (http://dev-edible-alpha.pantheonsite.io/?s). However, I am wanting any search made from one of the user landing pages to already have that category selected for the resulting search page. In the example above, this would mean having the “For Consultants” category checked with only the associated content displayed for any search performed from the consultants page.

    I think this is possible with shortcodes (https://www.designsandcode.com/documentation/search-filter-pro/getting-started/creating-your-first-search-form/#shortcodes) for that particular search, including only the content w/the appropriate category. However, I am wanting, once they get to the search page, to have the ability to access all of the results if they wish, rather than just the content curated for them.

    Are there any options for this?

    Zac

    Trevor
    #120637

    Yes. Your form should have that taxonomy as a field. You can use custom CSS to ‘hide’ that field on their landing pages. As the landing page is a taxonomy page, on the General Settings tab, Find the setting for Choose which kinds of pages S&F will try to do this on and switch on Tag, Category & Taxonomy Archives

    This will auto fill that hidden field, and thus that will be passed to the results page.

    Anonymous
    #120641

    Thanks for the prompt reply!

    What if the page is just a regular page, not a taxonomy page. If I add the category to this page but don’t select “Tag, Category & taxonomy Archives”, will the basic idea still work?

    Trevor
    #120643

    It must be a Taxonomy page, as seen by WordPress. For a normal page this will not work. Instead you would do almost the same thing, but add a custom javascript on that page to set the hidden field to the setting you wanted when the page had loaded (on Document ready). Whilst this example is for a date, it will give you an idea:

    <script type="text/javascript">
    jQuery( document ).ready(function($){
      var now = new Date();
      var today = ('0' + now.getDate()).slice(-2) + '/'
                 + ('0' + (now.getMonth()+1)).slice(-2) + '/'
                 + now.getFullYear();
      jQuery('li:first-child input[name="_sfm_transportation_dummy_start_date[]"]').val(today);
      jQuery('li:last-child input[name="_sfm_transportation_dummy_start_date[]"]').val('31/12/2050');
    });
    </script>

    Your example would be much simpler, needing something like the last line of code.

Viewing 4 posts – 1 through 4 (of 4 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.