Skip to content

Instantly share code, notes, and snippets.

/functions.php Secret

Created November 21, 2013 20:30
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 anonymous/31518bbee8aa1f50a243 to your computer and use it in GitHub Desktop.
Save anonymous/31518bbee8aa1f50a243 to your computer and use it in GitHub Desktop.
<?php
/*
* Show posts assigned to 'International (intl)' Edition
* in all editions.
*/
function wtnerd_better_editions( $query ) {
if ( $query->is_category() && $query->is_main_query() ) {
$query->set( 'post_type', array( 'post' ) );
// Get current tax query
$tax_query = $query->get( 'tax_query' );
$tax_query['relation'] = 'OR';
$tax_query[] = array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => 'intl',
'operator' => 'IN'
);
$query->set( 'tax_query', $tax_query );
}
return $query;
}
add_action( 'pre_get_posts', 'wtnerd_better_editions' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment