Skip to content

Instantly share code, notes, and snippets.

Created December 25, 2011 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/1519659 to your computer and use it in GitHub Desktop.
Save anonymous/1519659 to your computer and use it in GitHub Desktop.
Excluded featured from main category query
<?php
function be_exclude_category_featured( $query ) {
if( $query->is_main_query() && $query->is_category() ) {
$meta_query = array(
array(
'key' => 'be_category_featured',
'value' => 'on',
'compare' => '!='
);
$query->set( 'meta_query', $meta_query );
}
}
add_action( 'pre_get_posts', 'be_exclude_category_featured' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment