Remove specific page/post from feed

I’m working on a website with lots of tutorials/pages.

I have made a separate rss feed for the pages – works fine.
But then I had to create a sitemap (a page), and it shows up in my “pages” rss feed!

Read More

My Question: How can I remove a specific post/page from a feed?

Related posts

Leave a Reply

2 comments

  1. The quick and dirty way is set the published date a year or so in the past, past the oldest posts in the feed. There’s also a nice plugin for this – Stealth Publish – where you set a flag in a custom field to exclude it from feeds and the home page feed.

  2. A simple custom solution is also possible and you have not the overflow of this plugin, the ui and so on.

    function fb_exclude_filter($query) {
        if ( !$query->is_admin && $query->is_feed) {
            $query->set('post__not_in', array(40, 9) ); // id of page or post
        }
        return $query;
    }
    add_filter( 'pre_get_posts', 'fb_exclude_filter' );
    

    for more background information see my post