A client of mine is using a Genesis theme with the Genesis Responsive Slider plugin. The category she is using for the slider is “Featured” and she asked that this category not show up on the blog itself. So I added this handy little snippet to remove the “Featured” category from the WordPress Loop.
To modify this snippet for your site, all you have to do is copy and paste it into your functions.php and change “5” with the category ID for the category you wish to remove from the WordPress Loop. Enjoy!
<?php | |
/** Exclude Specific Categories From The WordPress Loop */ | |
add_action( 'pre_get_posts', 'hjs_exclude_categories' ); | |
function hjs_exclude_categories( $wp_query ) { | |
if( !is_admin() && is_main_query() && is_home() ) { | |
$wp_query->set( 'cat', '-5' ); | |
} | |
} | |
?> |