Skip to content

Instantly share code, notes, and snippets.

@mfields
Created October 12, 2012 01:25
Show Gist options
  • Save mfields/3876827 to your computer and use it in GitHub Desktop.
Save mfields/3876827 to your computer and use it in GitHub Desktop.
/**
* Exclude asides from the blog queries.
*/
function mytheme_pre_get_posts( $query = false ) {
// Bail if not home, not a query, not main query.
if ( ! is_home() || ! is_a( $query, 'WP_Query' ) || ! $query->is_main_query() )
return $query;
// Exclude aside formatted posts from the main query.
$query->query_vars['tax_query'] = array(
array(
'field' => 'slug',
'taxonomy' => 'post_format',
'terms' => array( 'post-format-aside' ),
'operator' => 'NOT IN',
),
);
return $query;
}
add_action( 'pre_get_posts', 'mytheme_pre_get_posts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment