• Resolved JeffW

    (@jeffw)


    I have a couple of categories of posts that I want to exclude from my RSS feed.

    How can I do this without hacking the code?

    I can’t see how to do this via a plugin, as I don’t know how to set a filter that only applies when RSS loops through the posts, but is not active when WP is diplaying posts on the site.

    Anybody got a quick solution for me? Point me in the right direction, and I will be able to finish off the plugin – provided there is a suitable RSS-specific hook that I can’t see at the moment.

    Thanks
    Jeff

Viewing 8 replies - 1 through 8 (of 8 total)
  • To exclude one category i.e. category 3, add the following to the root index.php before the include to wp-blog-header.php:
    if(isset($_GET['feed'])) {
    $cat=-3;
    }

    To exclude multiple categories i.e. 3,4 and 5, you’ll have to work backwards and include only the categories that you want i.e.
    if(isset($_GET['feed'])) {
    $cat='1 2 6';
    }

    Apologies, just read your post a bit more carefully and realised that you want to do this via plugin hooks and without hacking the code.

    I’ll leave my above post up for reference but someone else will have to chime in to answer your specific request.

    Download this plugin:

    http://www.redalt.com/External/plugins.php?p=front-page-cats

    First you have to edit the $cats_to_show varariable in the plugin file to list the categories to display. Next, look for this bit (you’ll find it in two places):

    $wp_query->is_home

    Change it to

    $wp_query->is_feed

    Upload the plugin file; activate it; the end. Oh, you may want to rename the plugin, so you don’t get confused by it a few months from now (look for the Plugin Name: line — perhaps you can call it “Feed Categories”).

    Thread Starter JeffW

    (@jeffw)

    Thanks for the prompt feedback.

    Sorry that I am only posting a response now – I found the front-page-cats code useful – learnt something new about tweaking WP / enabled me to achieve what I wanted.

    Jeff

    JeffW, I want to do the same thing. Is it possible for you to share the code to do that ?

    TIA,

    ckozus.

    This is a great workaround for excluding or including certain categories in a feed.

    Unfortunately, our site’s need to employ the permalink structure category/postname breaks the feed. There is a long error message with the header “[Not unique table/alias: ‘wp_post2cat’]”. The feed can be restored by deactivating the plugin, or changing the permalink structure to anything else.

    The burden of the category/postname permalink!

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Get the Category Visibility plugin. It can hide categories in lots of different ways, one of which is to remove them from the feed.
    http://www.gudlyf.com/archives/2005/03/08/wordpress-plugin-category-visibility/

    Txs for the tip. That plugin (updated here) works great for our particular setup. Much appreciated.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘RSS Feed – Exclude Some Categories’ is closed to new replies.