Skip to content

Instantly share code, notes, and snippets.

@IkeTen
Forked from anonymous/gist:1519659
Created November 16, 2016 19:47
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 IkeTen/8a329052df89da4cb71400c91ca47b59 to your computer and use it in GitHub Desktop.
Save IkeTen/8a329052df89da4cb71400c91ca47b59 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