[Resolved] Exclude post format from main query
I’m wanting to use
pre_get_poststo exclude some posts from my main query — I want to include only ‘standard’ post formats in the main portion of the blog, and exclude ‘video’ and ‘aside’ post formats.
The query I’ve got in place now sort of accomplishes what I want:
<?php $args = array( 'tax_query' => array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-video','post-format-aside'), 'operator' => 'NOT IN' ) ) ); $main_blog = new WP_Query(); // Main blog query $main_blog->query( $args ); ?> <?php if ( $main_blog->have_posts() ) : while ( $main_blog->have_posts() ) : $main_blog->the_post(); //Main blog loop ?>
But this isn’t really the right way to change the main query, right? For one thing, it breaks the “older posts” link at the bottom of the home page.
Can anyone help me with the code for using
pre_get_poststo accomplish this. I guess I need to use
tax_query? There doesn’t seem to be any way to directly reference “post formats.” Thank you!
- The topic ‘[Resolved] Exclude post format from main query’ is closed to new replies.