WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to exclude posts from aside post-format in the feed. I have already checked up here about how to exclude posts from a certain post format from the loop but how to exclude posts from a post format in the feed? Couldn't modify it because I am not very good with the code.

share|improve this question
up vote 1 down vote accepted

If you want to modify the feed, you should hook into the main query that WordPress will do on every page request. The best hook here is pre_get_posts. This code example will hook into pre_get_posts, check whether it is a feed, and add the post format taxonomy query:

add_action( 'pre_get_posts', 'wpse18412_pre_get_posts' );
function wpse18412_pre_get_posts( &$wp_query )
    if ( $wp_query->is_feed() ) {
        $post_format_tax_query = array(
            'taxonomy' => 'post_format',
            'field' => 'slug',
            'terms' => 'post-format-image', // Change this to the format you want to exclude
            'operator' => 'NOT IN'
        $tax_query = $wp_query->get( 'tax_query' );
        if ( is_array( $tax_query ) ) {
            $tax_query = $tax_query + $post_format_tax_query;
        } else {
            $tax_query = array( $post_format_tax_query );
        $wp_query->set( 'tax_query', $tax_query );
share|improve this answer
Thanks for the prompt response. I tried your code but it didn't work for me. – navjotjsingh May 27 '11 at 8:25
@navjotjsingh: Indeed, my code contained a small error: the taxonomy query is an array of arrays. I tested and corrected my example. – Jan Fabry May 27 '11 at 8:54
Thanks a ton. It works now. – navjotjsingh May 27 '11 at 9:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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