Looking for support? You can access the support system via your account.
- This topic has 5 replies, 3 voices, and was last updated 9 years, 9 months ago by .
You must be logged in to reply to this topic.
Looking for support? You can access the support system via your account.
Forums › Forums › Search & Filter Pro › Search filter for specific product category
Hi,
Not sure if this is realted to the following topic here: https://support.searchandfilter.com/forums/topic/results-showing-from-excluded-categories/, but I was not able to achive what I want with the solutions there.
So the idea is to have a search filter, which works only with a specific product category. This includes all taxonomies which are listed in the search form/filters to be for products from this category and the products that are also listed as result to be only from that category.
Can you give any advise on how to do that?
Thanks in advance
Hey there, just to let you know I will be looking at this tonight.
Thanks
Hi Ross,
I’ll be waiting for your replay.
Thanks.
Hey Branimir sorry this slipped through the net, I’ll try to take a look later or tomorrow.
Thanks
I think I may be looking for the same thing, if I understand the original post correctly. I have a content type with a few taxonomies, and have set up filters on a particular page to search among them. Works great.
Elsewhere on the site, I want to set up the same search filters, but I want the possible search results to be restricted to those where a particular value in a particular custom taxonomy is selected. I think this is the same as Branimir’s goal to restrict results to a particular product category.
Thanks in advance for any help!
Hey both please see this thread:
https://support.searchandfilter.com/forums/topic/excluded-categories-on-specific-forms/
Does this look like what you are trying to achieve? The code from that thread is below (just add to functions.php):
function modify_search_filter_query( $query )
{
global $sf_form_data;
global $wp_query;
if ( $sf_form_data->is_valid_form() && $query->is_main_query() && !is_admin())
{
if($sf_form_data->form_id()==12) //where the form ID is 12
{
//modify the query for a form with id 12
$query->set( 'cat', '-2' );
}
else if($sf_form_data->form_id()==99) //where the form ID is 99
{
//modify the query for a form with id 99
$query->set( 'cat', '-20' );
}
}
}
add_action( 'pre_get_posts', 'modify_search_filter_query', 21 );
You can get the ID of the form by looking at the URL in the edit screen (when editing your S&F form)
http://www.yoursite.com/wp-admin/post.php?post=797&action=edit
In this case it would be 797.
Hope that helps 🙂
You must be logged in to reply to this topic.
© 2024 Search & Filter Support. All Rights Reserved.
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.
Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.
*Other cookies used for logging in and cart functions will only be used when you use those features and cannot be disabled.
If you disable these cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.
This website uses Google Analytics to collect anonymous information such as the number of visitors to the site, and the most popular pages.
Keeping this cookie enabled helps us to improve our website.
Please enable Strictly Necessary Cookies first so that we can save your preferences!
More information about our Cookie Policy