Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created June 28, 2012 20:48
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/3013827 to your computer and use it in GitHub Desktop.
Save billerickson/3013827 to your computer and use it in GitHub Desktop.
<?php
/**
* Exclude 'Behind the Scenes' category from blog
* @author Bill Erickson
* @link http://www.billerickson.net/customize-the-wordpress-query/
*
* @param object $query
*/
function be_modify_blog_query( $query ) {
if( $query->is_main_query() && $query->is_home() ) {
$tax_query = array(
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => 'behindthescenes',
'operator' => 'NOT IN',
)
);
$query->set( 'tax_query', $tax_query );
}
}
add_action( 'pre_get_posts', 'be_modify_blog_query' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment