I'm trying to have my search results show only results that are a child of the 'news' category or a child of the 'work' page (ID = 16).
This is what I have so far:
function SearchFilter($query) {
if ($query->is_search) {
$query->set('category_name', 'news');
$query->set('post_parent', '16');
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');
The problem is it only searches for posts that belong to 'news' AND have a parent page ID of '16', which is obviously no posts.
So how do better refine search? I'd prefer not to use a plugin, that's why i am here.
Thanks, Drew