Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created January 30, 2014 21:24
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 billerickson/8720154 to your computer and use it in GitHub Desktop.
Save billerickson/8720154 to your computer and use it in GitHub Desktop.
<?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