Search Posts Only


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



Copy this code and paste it in your HTML
  1. // Search Post only not Pages
  2. function vibeExcludePages($query) {
  3. if ($query->is_search) {
  4. $query->set('post_type', 'post');
  5. }
  6. return $query;
  7. }
  8. add_filter('pre_get_posts','vibeExcludePages');
  9. ; ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.