Feedsby Internet Solutions

How to Exclude Categories or Posts From Your WordPress Feed

31 Ogos 20268 min bacaanSuapan RSS
How to Exclude Categories or Posts From Your WordPress Feed

Short answer: You can keep posts out of the WordPress feed in four ways: a plugin setting, a small pre_get_posts snippet that excludes a category only when is_feed() is true, a dedicated tag that marks single posts, or publishing a separate category feed for the audience that needs a narrower selection. Exclude by category or a dedicated tag rather than by post ID, test the result in the raw feed, and remember that readers do not remove items they have already downloaded.

Not everything you publish belongs in your main feed. Sponsored posts, job ads, internal announcements, event reminders or a daily “link roundup” might suit your website visitors but annoy the feed readers, newsletter tools and partners who consume your feed. WordPress includes every standard post in the main feed by default. Changing that is easy, but a careless change can empty the feed or exclude posts from the website as well. This guide shows the safe options.

Decide what to exclude, and why

Before touching settings, be clear about the goal. Typical reasons include:

Write the rule down in one sentence, for example “Sponsored posts never appear in the main feed”, and share it with everyone who publishes. A clear rule decides which technical approach fits: a rule about a whole category suggests category exclusion, while a rule that depends on judgement post by post suggests a tag or an opt-in feed.

The last reason is increasingly common. If a feed drives automation, excluding a post from the feed is the simplest way to stop it being shared automatically.

Option 1: use a plugin setting

Several SEO and feed-management plugins include an option to exclude categories, tags or individual posts from feeds. The advantages are obvious: no code, and non-technical editors can manage it. When choosing a plugin:

Option 2: exclude a category with code

A small snippet in a site-specific plugin or child theme does the job reliably. This example excludes category ID 12 from the main feed:

add_action( 'pre_get_posts', function ( $query ) {
    if ( $query->is_main_query() && $query->is_feed() && ! $query->is_category() ) {
        $query->set( 'category__not_in', array( 12 ) );
    }
} );

Key details:

Option 3: exclude individual posts with a tag or field

Sometimes you want to exclude a single post without creating a category for it. A common pattern is a dedicated tag, such as “no-feed”, or a checkbox custom field. With a tag:

add_action( 'pre_get_posts', function ( $query ) {
    if ( $query->is_main_query() && $query->is_feed() ) {
        $tag = get_term_by( 'slug', 'no-feed', 'post_tag' );
        if ( $tag ) {
            $query->set( 'tag__not_in', array( $tag->term_id ) );
        }
    }
} );

Editors then simply add the tag to any post that should stay out of the feed. Consider hiding that tag from public tag clouds and making its archive noindex, since it is an internal marker rather than a real topic. Avoid hard-coding lists of post IDs: nobody remembers to update them, and they fail silently.

Option 4: publish a separate feed instead

Excluding is not the only approach. If one audience needs a narrower selection, give them a narrower feed and leave the main feed complete:

WordPress makes this almost free: every category and tag already has its own feed, so the only work is creating the category and telling each consumer which URL to use. You can even add a post to the “Share” category after publishing, and automation tools that check the feed will pick it up on their next fetch.

This inversion, including by choice rather than excluding by exception, is often cleaner for automation. It turns sharing into a deliberate action and avoids surprises when someone forgets to tag a post.

Hiding parts of a post rather than the whole post

Sometimes the post belongs in the feed, but part of it does not: an embedded form that will not work in readers, a large promotional banner, a comments call-to-action, or a gallery that renders as a long list of images. Rather than excluding the post, trim the feed version:

This keeps the feed complete while making each item cleaner in readers, newsletters and partner sites. It is also kinder to subscribers than silently removing posts they might have wanted, and it avoids the confusion of a reader noticing that the website shows articles the feed never delivered.

Comparing the approaches

Approach Effort Flexibility Risk
Plugin setting Low Medium Plugin conflicts or updates
Category exclusion code Low Category level Wrong ID empties or misses content
Tag or field exclusion Low to medium Per post Editors forget the tag
Separate opt-in feed Low High Consumers must use the right URL

Testing and side effects

After any change, check:

  1. The raw main feed at /feed/: the excluded posts are gone and other posts remain.
  2. The Atom feed at /feed/atom/ and any category feeds you rely on.
  3. The blog page, archives and search: nothing disappeared from the website.
  4. Caches: purge page and CDN caches so the new feed is served.
  5. Downstream tools: publish a test post in the excluded category and confirm your newsletter or social tool ignores it.

Keep the snippet or plugin setting documented in the same place as your other site notes. Months later, when someone asks why a post is missing from the newsletter, the answer should take one minute to find, not an afternoon of debugging.

Remember that excluding a post that was already published does not remove it from readers that have fetched it. Exclusion only affects future fetches. If an item must be withdrawn everywhere, unpublish or edit the post itself as well.

When the feed you want is someone else’s

You can only change the feeds of sites you control. If you consume another site’s feed and want to leave out certain items, such as sponsored posts or a topic you do not need, filter it after the fact. Our tool, Feeds, can keep only items that contain your words or drop items that contain them, and merge several sources into one filtered feed with duplicates removed. The result is an ordinary RSS link for any reader or tool. See the plans.

Related reading

The bottom line

WordPress puts every standard post in its main feed, but excluding content is simple: use a plugin setting, a small pre_get_posts snippet limited to feeds, a dedicated “no-feed” tag, or a separate opt-in category feed for special audiences. Test the raw feed and your website after the change, purge caches, and remember that exclusion only affects future fetches.

FAQ

How do I remove a category from my WordPress RSS feed?

Use a plugin with a feed exclusion setting, or add a pre_get_posts snippet that sets category__not_in when is_feed() is true. Use the category ID, and test the raw feed afterwards.

Will excluding a category from the feed hide it on my website?

Not if the code checks is_feed(). The condition limits the change to feeds, so the blog page, archives and search keep showing the category’s posts.

Can I exclude a single post from the feed?

Yes. Add a dedicated tag such as no-feed or a custom field, and exclude posts with that tag or field in feeds. Avoid hard-coded post ID lists, which are easy to forget.

Why does an excluded post still appear in my reader?

Readers keep items they already downloaded. Exclusion only affects future fetches. Also check that page and CDN caches were purged after the change.

Is it better to exclude posts or create a separate feed?

For automation and partners, a separate opt-in category feed is often cleaner, because only deliberately chosen posts are shared. Exclusion suits cases where most posts belong in the feed and only a few do not.

#Publishing#RSS#WordPress
Cipta suapan pertama anda — percuma.Suapan daripada mana-mana halaman. Setiap produk dalam setiap katalog.
Mula percuma

Lagi dari blog

Semua artikel →
Internet Solutions

Lagi daripada pasukan kami

Dibina oleh Internet Solutions. Cuba produk kami yang lain — setiap satu menjimatkan masa anda dengan cara berbeza.

internet-solutions.net ↗
Feeds
Gambaran Keseluruhan Privasi

Laman web ini menggunakan kuki supaya kami dapat memberikan pengalaman pengguna yang terbaik. Maklumat kuki disimpan dalam pelayar anda dan menjalankan fungsi seperti mengenali anda apabila anda kembali ke laman web kami serta membantu pasukan kami memahami bahagian laman web yang paling menarik dan berguna bagi anda.