WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Exclude postings from main RSS feed?

[Resolved] Exclude postings from main RSS feed?

  • I was wondering if it’s possible to exclude entries from:

    1) being posted on the homepage (instead, they will be posted in a separate category)
    2) showing up in the main RSS feed.

    Thank you!

Viewing 11 replies - 1 through 11 (of 11 total)
  • There are a number of ways to exclude a category from the home page or main feed. Here’s one that hits both at the same time…

    Place the following in the index.php of your blog’s root (just above the line calling wp-blog-header.php):

    if(empty($_SERVER['QUERY_STRING']) || (isset($_GET['feed']) && !(isset($_GET['cat']) || isset($_GET['category_name'])))) {
    $cat=-1;
    }

    Change $cat=-1; to the category ID you want to exclude (prefixed with the minus sign).

    Thanks so much! Would if work if I want to exclude more than one category?

    You’d have to do an exclude through an include (so to speak) by assigning to $cat the categories you want displayed (and not the ones you want to hide):

    $cat='2, 3, 4, 5';

    Not pretty if you’ve got 100 categories, but I didn’t say it’s perfect.

    Hey guys,

    I’m reading this with much interest – as I need to exlude 2 categories from my website – but the code needs to be different as I’m using php to extract data from mySQL and feed it into a Flash website.

    Can anyone how to tweak this code to exclude category IDs 1 and 2?

    /* Fetch all the data from wp_posts table */
    for ($i=0; $i< $nRows; $i++){
    $row = mysql_fetch_array($qResult);
    $rString .="&ID".$i."=".$i."&"."&post_title".$i."=".$row['post_title']."&"."&post_date".$i."=".$row['post_date']."&"."&post_content".$i."=".$row['post_content']."&";
    }
    /* Output the data as a string so Flash can read it */
    echo $rString."&";

    Cheers 🙂

    u have to have a filter condition to scrap the cats u dnt want capsulating your for loop so your condition can say until the post is not related to cat 1 and cat 2 post the rest..hope this helps

    Kafkaesqui you said “You’d have to do an exclude through an include (so to speak) by assigning to $cat the categories you want displayed (and not the ones you want to hide):

    $cat=’2, 3, 4, 5′; “
    It works fine but there is a minor problem. When i do like that on the homepage on the side bar it says “You are currently browsing the …..” so it says your browsing the archieve of the category “2” presented in the code above..
    which is the very first category..but if you do a single exclusion such as $cat=-4; it wont show any.. i have more than one category to eleminate from homepage so i had to use the above code..unless there is an alternative 🙂 please help out..many thanks!

    Hey guys,

    I just started using the Sideblog plugin (http://katesgasis.com/2005/10/24/sideblog/) and I want to exclude the Asides from my RSS feed. It would seem Kafkaesqui has offered the solution above, but in my theme (Rin) there is no wp-blog-header.php call, so I don’t know where to insert the code. Putting it up top doesn’t work. Please help me out here, I really have no idea what I’m doing! Thanks–

    Ryan

    is not in theme, nofilmeschool, is index.php of your root…
    not index.php of your theme.

    I have a requirement which is slightly different from the one this thread is for.
    I want
    1) to exclude a category from main page.
    (same as the above 1st point)
    2) to “show” those posts in main feed.
    (negative of the above2)

    bartman316

    @bartman316

    I’ve tried this but it is not working. The site is functioning the same as before this line was added to the index.php code. Am I missing something?

    Kafkaesqui

    @kafkaesqui

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Resolved] Exclude postings from main RSS feed?’ is closed to new replies.
Skip to toolbar