Skip to main content
WordPress made easy with the drag & drop Total WordPress Theme!Learn More

Exclude Post Formats From WordPress Custom Loop

Last updated on:

I’ve recently released a new Premium WordPress Photography Theme and while setting up the blog section I added several different post formats – quotes, links, video, images and standard. This was great for showcasing various content on the blog, however, I didn’t want to have any actual posts for the quotes/link port formats because they have such little content, so I decided to remove any permalink structure for these.

The issue became when I was setting up a custom archives template, because I didn’t want any of the quote or link posts to show up since they don’t have any content. So after some messing around I came up with a great way to exclude any post formats from your custom WordPress loops by using a tax_query within my get_posts argument to exclude these post formats.

Below is a quick sample loop of how to exclude post formats using the tax_query.

$args = array(
 'numberposts' => 10,
 post_type' =>'post',
 'tax_query' => array(
 'taxonomy' => 'post_format',
 'field' => 'slug',
 'terms' => array( 'post-format-quote','post-format-link' ),
 'operator' => 'NOT IN',
 $posts= get_posts($args);

How the Tax Query Works?

We are basically using the tax query to show any posts that are  “Not In” the terms array which consist of quote and link post formats. Of course you can add in any post format you wish to exclude just like I have done by separating them with comas.  Checkout the post on about “Taxonomy Parameters” for further reading and usage.

Subscribe to the Newsletter

Get our latest news, tutorials, guides, tips & deals delivered to your inbox.


  1. HAMZA

    hey so si have a tabs widget and i have recent posts section in it and i want to exclude the post format from it and i dont know what to do this is the code of my function

    • AJ Clarke

      Your code didn’t go through well via the comments, send me a link to the code on a gist or pastebin and I’ll have a look.

Leave a Reply

Your email address will not be published. Required fields are marked *

Learn how your comment data is processed by viewing our privacy policy here.