Search posts in a specific category
-
Hello, I’m looking to show a list of posts from a search in multiple categories. Complicated!!
In general, my
'cat' => array(1,2,3)
doesn’t work, but that’s another issue, though I think it’ll make an appearance in this thread.So, first, I need to define the content of the search – using the search_query?
Then I need to direct the search to three different categories.I’d like to do this without setting new a new post_type, but if necessary, I did find this code that could help:
function SearchFilter($query) { if ($query->is_search) { // Insert the specific post type you want to search $query->set('post_type', 'feeds'); } return $query; } // This filter will jump into the loop and arrange our results before they're returned add_filter('pre_get_posts','SearchFilter');
And, for reference if necessary, a good tutorial on setting up post_type.
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Search posts in a specific category’ is closed to new replies.