Exclude Post Formats in WordPress Custom Loop

As a WordPress developer, I recently faced an issue while setting up a custom archives template for a new Premium WordPress Photography Theme. I had added several different post formats, including quotes, links, video, images, and standard, to showcase various content on the blog. However, I didn’t want any actual posts for the quotes/link post formats because they have such little content. So, I decided to remove any permalink structure for these post formats.

The problem arose when I was setting up a custom archives template. I didn’t want any of the quote or link posts to show up since they don’t have any content. After some trial and error, I came up with a great way to exclude any post formats from custom WordPress loops by using a tax_query within my get_posts argument to exclude these post formats.

Here’s 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);

So, how does the tax_query work? We are basically using the tax_query to show any posts that are “Not In” the terms array, which consists 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 commas.

If you want to learn more about taxonomy parameters and their usage, you can check out the post on WordPress.org about “Taxonomy Parameters.”

In conclusion, excluding post formats from custom WordPress loops is an essential step in setting up a custom archives template. By using the tax_query, you can easily exclude any post format that you don’t want to show up in your custom loop. This technique can save you a lot of time and effort in the long run.

Stay in Touch


Related Articles