The title basically says it all.

I know I can use the following to get posts from the aside post format:

$args = array(
    'post_type'=> 'post',
    'post_status' => 'publish',
    'order' => 'DESC',
    'tax_query' => array(
        array(
            'taxonomy' => 'post_format',
            'field' => 'slug',
            'terms' => array( 'post-format-aside' )
        )
    )
);

$asides = get_posts( $args );
foreach ( $asides as $aside ) {
    setup_postdata( $aside );
    // HTML...
}

What I would like to know is how do I get posts that are not in the aside post format?

link|improve this question

75% accept rate
feedback

1 Answer

up vote 3 down vote accepted

You just need to set the operator parameter to 'NOT IN' (see Codex on tax queries).

Untested, but for your purposes:

$args = array(
    'post_type'=> 'post',
    'post_status' => 'publish',
    'order' => 'DESC',
    'tax_query' => array(
        array(
            'taxonomy' => 'post_format',
            'field' => 'slug',
            'terms' => array( 'post-format-aside' ),
            'operator' => 'NOT IN'
        )
    )
);
link|improve this answer
1  
Thanks. On a side note: I wish there were a simpler way to query post formats. Something like this: 'post-format' => array('aside'). – MegaHit Feb 8 at 0:07
feedback

Your Answer

 
or
required, but never shown

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