Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

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'
        )
    )
);
share|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 '12 at 0:07
add comment

Your Answer

 
discard

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.