Posted By

adambundy on 10/25/12


Tagged

wordpress


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

adambundy
Alpatrose


Wordpress exclude certain category IDs from main or front page


 / Published in: PHP
 

Add to functions.php. Replace IDs (64, 104 below) with categories you want to exclude.

  1. function BI_exclude_category( $query ) {
  2. if ( $query->is_home() && $query->is_main_query() ) {
  3. $query->set( 'cat', '-64,-104' );
  4. }
  5. }
  6. add_action( 'pre_get_posts', 'BI_exclude_category' );

Report this snippet  

You need to login to post a comment.