If you’re using the WordPress 3.1 Post Formats feature to publish formatted content (like ‘aside’, ‘status’, ‘chat’, ‘quote’, etc.), it’s likely that you’ll want to exclude certain post formats from your RSS feed so as not to clutter up peoples viewers with random crap.
For me, that means removing status posts – short-form updates, under 140 characters (often cross-posted from Twitter) and aside posts – random thoughts or short paragraphs, without title (or intellectual value, usually.)
1. Open up your theme’s functions.php file and insert the following code (in case you’re not 100% up on PHP, just make sure it’s inside <?php ?> tags or your site will break.)
// Hide post formats from WordPress generated RSS feeds:
function exclude_post_formats_from_feeds( &$wp_query ) {
// Only do this for feed queries:
if ( $wp_query->is_feed() ) {
// Array of post formats to exclude, by slug,
// e.g. "post-format-{format}"
$post_formats_to_exclude = array(
'post-format-status',
'post-format-aside'
);
// Extra query to hack onto the $wp_query object:
$extra_tax_query = array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => $post_formats_to_exclude,
'operator' => 'NOT IN'
);
$tax_query = $wp_query->get( 'tax_query' );
if ( is_array( $tax_query ) ) {
$tax_query = $tax_query + $extra_tax_query;
} else {
$tax_query = array( $extra_tax_query );
}
$wp_query->set( 'tax_query', $tax_query );
}
}
// Call the above hook function before every WordPress query:
add_action( 'pre_get_posts', 'exclude_post_formats_from_feeds' );
2. Edit the array of post formats to exclude. In the example, I’ve excluded ‘status’ and ‘aside’ formats, but you can do any (in the format post–format–{aside/gallery/link/image/quote/status/video/audio/chat}.
The above code is fairly self-explanatory – it is fired on every WordPress request, but only activates if it’s a feed, and removes the formats you supplied (in this case, ‘status’ and ‘aside’ will be excluded).
In any case, comment below if you need any advice or help. Good luck!
Based on wordpress.stackexchange.com/questions/18412/how-to-exclude…


Joss, thanks for this post; this is exactly 100% what I was looking for and you saved me having to troll through 50 non-specific, unrelated sites to find how to do this properly. THANKYOU!!!
Cool, thanks for the comment!
Joss, sorry to bother you for help, but I can’t seem to get this to work. I’ve been using WordPress and PHP for a long time, but just recently added a functions.php file to my very old custom theme. When I first copied in your code, I started getting fatal PHP errors of this type:
PHP Fatal error: Cannot redeclare exclude_post_formats_from_feeds() (previously declared in …
When I wrapped the code in a “if ( ! function_exists( ‘exclude_post_formats_from_feeds’ ) ) :” wrapper, I stopped getting the errors and post format posts were excluded from my RSS feed. Unfortunately, it seems like *all* posts are now excluded from my feed. Actually, I take that back – I just added the feed to a different reader and it’s only pulling posts from several years ago. No recents posts of any format are showing up, though.
I’m running the latest version of WordPress without a ton of custom plugins, but I guess it’s possible one of them is conflicting with this code. Do you have any suggestions?
On a side note, I used to work for an airline and had the pleasure of visiting Hong Kong once – what an exciting place!
Thanks for your time…
Cheers, DK
Hey, no worries! Looks like another plugin has a function with the same name, and the
function_existsblock you put in is causing the hack to use that function instead (one possibility)Fix: try renaming the function in functions.php to
dk_exclude_post_formats_from_feeds, and update theadd_actionto use that function – let me know if that fixes it.You may not see the changes immediately in your feed reader because of caching, so try another reader if it doesn’t seem to help – and let me know if it works!