Posted By

goatboy91587 on 12/21/11


Tagged

wordpress


Versions (?)

Filter Category from WordPress Blog Page


 / Published in: PHP
 

URL: http://www.brettwidmann.com/2011/12/filter-categories-wordpress-blog/

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.

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

Report this snippet  

You need to login to post a comment.