Exclude Posts or Pages from Wordpress Search Results


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function SearchFilter($query) {
  2. if ($query->is_search) {
  3. $query->set('cat','0,1');
  4. }
  5. return $query;
  6. }
  7.  
  8. add_filter('pre_get_posts','SearchFilter');

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.