Wordpress Search Function to only search posts Wordpress Search Function to only search posts wordpress wordpress

Wordpress Search Function to only search posts


Answer is here

http://www.shilling.id.au/2011/06/23/wordpress-search-only-show-post-and-not-pages/

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


Simply add <input type="hidden" name="post_type" value="post" /> to the theme search form... regards!


This wp forum page has a bunch of different examples of how to do this depending on where you want to edit your site (index.php or wp-includes/query.php are your options I believe):

http://wordpress.org/support/topic/possible-search-only-posts-exclude-pages