WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Exclude postings from main RSS feed? (12 posts)

  1. cbasturea
    Member
    Posted 9 years ago #

    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!

  2. Kafkaesqui

    Posted 9 years ago #

    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).

  3. cbasturea
    Member
    Posted 9 years ago #

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

  4. Kafkaesqui

    Posted 9 years ago #

    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.

  5. 3stripe
    Member
    Posted 8 years ago #

    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 :-)

  6. janantha
    Member
    Posted 8 years ago #

    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

  7. janantha
    Member
    Posted 8 years ago #

    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!

  8. nofilmschool
    Member
    Posted 8 years ago #

    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

  9. FakeStar
    Member
    Posted 8 years ago #

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

  10. rk
    Member
    Posted 8 years ago #

    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)

  11. bartman316
    Member
    Posted 7 years ago #

    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?

  12. Kafkaesqui

    Posted 7 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags