Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created March 6, 2014 17:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save billerickson/9395154 to your computer and use it in GitHub Desktop.
<?php
/**
* Customize Blog Query
*
*/
function be_blog_query( $query ) {
if( $query->is_main_query() && !is_admin() && $query->is_home() ) {
$tax_query = array(
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => array( 'cat-1', 'cat-2', 'cat-3' ),
'operator' => 'IN', // change this to AND for only posts in all listed categories
)
);
$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