The following snippet will limit search results to display blog posts only on your search results page. Copy and paste the following into functions.php


function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');

Source: http://www.wpbeginner.com/wp-tutorials/how-to-exclude-pages-from-wordpress-search-results/

Leave a Reply

Get in Touch

Please fill out the form below and we will get back to you ASAP