Forums › Forums › Search & Filter Pro › Custom Filter Applied to Initial Search Results
Tagged: Category Filters, search results page, shortcodes
- This topic has 3 replies, 2 voices, and was last updated 7 years, 4 months ago by Trevor.
-
Anonymous(Private) July 14, 2017 at 4:14 pm #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(Private) July 14, 2017 at 5:01 pm #120637Yes. 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 onTag, Category & Taxonomy Archives
This will auto fill that hidden field, and thus that will be passed to the results page.
Trevor(Private) July 14, 2017 at 5:40 pm #120643It 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.
-
AuthorPosts