• Resolved victorcarvalhosp

    (@victorcarvalhosp)


    Hi team,

    How can I exclude categories from search results? I created an “Archive” category, but would not like these articles to appear in the search results.

    I tried with this code:

    function exclude_category_from_search($query) {
    	if ($query->is_search) {
    		$cat_id = get_cat_ID('archive');
    		$query->set('cat', '-'.$cat_id);
    	}
    	return $query;
    }
    add_filter('pre_get_posts','exclude_category_from_search');

    But it didn’t work for the plugin categories! Can you give some help?

Viewing 1 replies (of 1 total)
  • Plugin Author echoplugins

    (@echoplugins)

    Hi,

    Thank you for reaching out. Unfortunately, we do not have the answer for your custom development. The KB core plugin does use the default WordPress search, you may need to debug this with your IDE and see how you can properly hook into it.

    Thank you,
    Dave.

Viewing 1 replies (of 1 total)
  • The topic ‘How to exclude categories from search results?’ is closed to new replies.