Skip to content

Instantly share code, notes, and snippets.

@QROkes
Created March 18, 2016 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QROkes/a2387c5e007d6def818d to your computer and use it in GitHub Desktop.
Save QROkes/a2387c5e007d6def818d to your computer and use it in GitHub Desktop.
WordPress exclude posts from Loop.
add_action( 'pre_get_posts', 'qr_exclude_tagged_posts' );
function qr_exclude_tagged_posts( $query ) {
if ( $query->is_main_query() && $query->is_home() ) {
$query->set( 'tag__not_in', array( 63 ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment