Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Exclude Specific Categories from the WordPress Loop
/** 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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.