WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to exclude all post formats but standard from a page template loop that displays 4 latest posts. For some reason I can't get the query to work.

This is my page template

global $paged, $wp_query, $wp;
$args = wp_parse_args($wp->matched_query);
if ( !empty ( $args['paged'] ) ) {
$wp_query->set('paged', $args['paged']);
$paged = $args['paged'];

 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
 query_posts('cat=0&posts_per_page=4&paged='.$paged); //set your own query here
 get_template_part( 'loop', 'portfolio' );


This is the loop

<?php $num_cols = 4; // set the number of columns here

for ( $i=1 ; $i <= $num_cols; $i++ ) :
    echo '<div class="column col-' . $i . '" >';
    $counter = $num_cols + 1 - $i; ?>

<?php while (have_posts()) : the_post();
    if( $counter%$num_cols == 0 ) :

// begin of core posts output ?>

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <header class="entry-header">
    <?php //end of posts output

    endif; $counter++;
        echo '</div>'; //closes the column div
    endfor; ?>
        <?php if (  $wp_query->max_num_pages > 1 || get_query_var('page')) : ?>
            <?php twentytwelve_content_nav( 'nav-below' ); ?>           
        <?php endif;
        wp_reset_query(); ?>

This is the query I've been trying to get to work with it

$args = array(
    'tax_query' => array(
            'taxonomy' => 'post_format',
            'field' => 'slug',
            'terms' => array( 'post-format-aside', 'post-format-image' ),
            'operator' => 'NOT IN'
$query = new WP_Query( $args );
share|improve this question
    'paged'=>$paged, //Pulls the paged function into the query
    'posts_per_page'=> 4, //Limits the amount of posts on each page
    'post_type'=>'post_type', //Set your allowed post types here
    'orderby' => 'title',
    'order' => 'ASC'


For more reference refer this.

You can pass the allowed post_type array to post_type argument in arguments array.

share|improve this answer
Wouldn't this only work for post types and not post formats? I need to exclude all formats but the standard post format – Jae Nov 6 '12 at 16:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.