Wednesday, February 22, 2012

How to Exclude Pages from WordPress Search Results

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

No comments:

Post a Comment