Return to Snippet

Revision: 60189
at October 25, 2012 03:10 by adambundy


Initial Code
function BI_exclude_category( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
        $query->set( 'cat', '-64,-104' );
    }
}
add_action( 'pre_get_posts', 'BI_exclude_category' );

Initial URL

                                

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

Initial Title
Wordpress exclude certain category IDs from main or front page

Initial Tags
wordpress

Initial Language
PHP