0

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?

1 Answer 1

4

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'
        )
    )
);
2
  • 2
    Thanks. On a side note: I wish there were a simpler way to query post formats. Something like this: 'post-format' => array('aside').
    – MegaHit
    Commented Feb 8, 2012 at 0:07
  • Works perfectly
    – rhysclay
    Commented May 3, 2017 at 1:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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