Filter Category from WordPress Blog Page

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

Ever want to filter out a category from your blog page. Here's how you do it! Just add this snippet to your functions.php file.

Copy this code and paste it in your HTML
  1. /* The Number 611 is my category ID number. Please replace this with your own!
  2.   Add this snippet to your functions.php file. */
  4. function exclude_cat($query) {
  5. if ( $query->is_home) {
  6. $query-> set('cat','-611');
  7. }
  8. return $query;
  9. }
  11. add_filter('pre_get_posts','exclude_cat');


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.