Forums › Forums › Search & Filter Pro › Exclude categories – documentation?
- This topic has 3 replies, 2 voices, and was last updated 11 years, 7 months ago by
Ross.
-
Anonymous(Private) October 1, 2014 at 6:16 pm #5384
Hi,
I see references in the forums to the ability to exclude categories from search. I can’t seem to find and reference in the documentation for this feature. I apologize in advance if I just missed it. I would also like to add my support for the “include” categories option that has been mentioned in the forums as well.
Thanks!
Ross Moderator(Private) October 1, 2014 at 9:02 pm #5389Hey Marlon
It was never implemented actually – there were several workounds but those no longer work.
Fortunately for you, I’ve just updated the plugin (v1.2.5) which has a settings panel where you can do this 🙂
Please check for updates and you should have what you need.
Thanks
RossAnonymous(Private) October 1, 2014 at 9:09 pm #5391Thanks! I was able to use this snippet of code to achieve the result I needed which I also found in the forums.
function filter_results( $query )
{
global $sf_form_data;
global $wp_query;if ( $sf_form_data->is_valid_form() && $query->is_main_query() && !is_admin() )
{
$query->set(‘cat’, ‘-1,-2,-3’); //you can use any query modifications from here – http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
}
}
add_action( ‘pre_get_posts’, ‘filter_results’, 21 );Ross Moderator(Private) October 1, 2014 at 11:22 pm #5399Hey Marion.that’s good news but I advise to switch over to the new way when you can to ensure future compatibility 🙂
Give me a shout if you have any problems
-
AuthorPosts