My latest RSS feed shows 20 posts for example, but I want to include a certain category no matter how old the post is (for example, my 'featured' post category), and also just get 1 latest post from this category.

I've been trying to look for plugins, but I'm not exactly sure what it would be called. Any help would be appreciated.

  • Welcome to WordPress Development. What have you tried so far? Plugin recommendations are off topic.
    – birgire
    Commented Jan 31, 2015 at 11:47
  • Ah ok sorry. I'm quite new to WP development but I'm using this: <?php $feed = get_the_content_feed('rss2'); ?> which obviously gets all the content from the latest feed (depending how many I set). I want to also add a condition to say get the latest feed as above, but also include 1 latest post from a category ID (to always appear in the feed). Sorry I hope I'm making sense Commented Jan 31, 2015 at 11:54

1 Answer 1


You can try the following:

 * A sticky feed post from a given category
 * @see http://wordpress.stackexchange.com/a/176706/26350

add_filter( 'the_posts', function( $posts )
    if( is_feed() 
        && $tmp = get_posts( array( 'category_name' => 'feed', 'posts_per_page' => 1 ) ) 
        $posts = array_merge( 
            wp_list_filter( $posts, array( 'ID' => $tmp[0]->ID ), 'NOT' ) 

    return $posts;
} );

where we prepend a given category post to the feed. Here you have to adjust the feed category slug to your needs. We also make sure that the sticky post isn't duplicated.

  • Hey that's brilliant - I would never have come up with that! Thanks for taking the time Commented Feb 1, 2015 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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