Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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