I have pages, posts and woocommerce product categories and products in my website. I want to limit wordpress default search query so that it returns the posts, the pages, the product categories but NOT individual products. I am using the following code in my functions.php
with which I can easily show only posts and pages. What I need now, is to show the woocommerce product categories along with my posts and pages in the search result, but NOT the individual products. Please help me out here.
function searchfilter($query) {
if ($query->is_search && !is_admin() ) {
$query->set('post_type',array('post','page'));
}
return $query;
}
add_filter('pre_get_posts','searchfilter');