Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Exclude issues from blog
*
*/
function be_blog_query( $query ) {
if( $query->is_main_query() && $query->is_home() && !is_admin() ) {
$terms = get_terms( 'issue-date' );
$terms = wp_list_pluck( $terms, 'term_id' );
$tax_query = array(
array(
'taxonomy' => 'issue-date',
'field' => 'term_id',
'terms' => $terms,
'operator' => 'NOT IN',
)
);
$query->set( 'tax_query', $tax_query );
}
}
add_action( 'pre_get_posts', 'be_blog_query' );
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.