Hi guys!
Is it possible to make the search box only search for articles and not pages? Or is it possible to disable the search box so I can use a plugin that allows me to control the results of the search, showing only articles.
Thanks!
Hi,
Please try this solution to exclude pages from search results – http://www.wpbeginner.com/wp-tutorials/how-to-exclude-pages-from-wordpress-search-results/
Paste the code in functions.php file – http://screencast.com/t/fhQDuIvjJ
function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');
Thanks!
-
This reply was modified 11 years by
Alin [tagDiv].
This is helpful on how to filter, but what if you want to weight them differently? We have 3 types of formats, but want to weight ‘standard’ (posts) higher than ‘video’ or ‘image’ (also posts, but the format of these are either video or image).
Is there way to make the ‘standard’ posts show up before the ‘video’ or ‘image’ posts? I don’t want to exclude them, just order the results differently.
If this is NOT possible, how do I exclude the ‘video’ or ‘image’ formats from the search results?
Thanks.

These might be useful on learning to setup custom queries for search:
http://biostall.com/filter-wordpress-search-results-by-one-or-more-post-types
http://codex.wordpress.org/Function_Reference/get_search_form