WordPress

Skipping post formats from query

October 14, 2014 /1 min read

If I do not want to show some post formats in any type of listing using custom query then this code is very helpful.

$myposts = new WP_Query( array(
    'tax_query' => array(
        array(                
            'taxonomy' => 'post_format',
            'field' => 'slug',
            'terms' => array( 
                'post-format-aside',
                'post-format-audio',
                'post-format-chat',
                'post-format-gallery',
                'post-format-image',
                'post-format-link',
                'post-format-quote',
                'post-format-status',
                'post-format-video'
            ),
            'operator' => 'NOT IN'
        )
    )
) );

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Let's build something exceptional.

I'm selectively available for consulting, security audits, plugin architecture, and product development partnerships. If you're building something that demands engineering excellence, I'd love to hear about it.

Looking for a detailed project estimation? Use Wizard

Fun Portfolio Projects

Cli Folio Comicbook Desktop Factory Game Folio Toons Folio
Hassan Raza