Support » Plugins » Hacks » Main RSS Feed – Show only posts from one category

  • I would like to have my main RSS feed to show posts from one category only.

    Is there a function that can help me achieve this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz


    Not exactly, you make your own! You use the same technique as would be done to alter any posts query. Hook into the ‘pre_get_posts‘ action. Use is_feed() to verify the query is for a feed, then set either ‘cat’ or category_name’ query vars to restrict the query to the specified category ID or slug.

    I understand what you are saying but I am not that good with the actual coding -:)

    Moderator bcworkz


    Enter your actual category slug (not name!) where indicated. Place in functions.php:

    add_action('pre_get_posts', 'mki_feed_cat');
    function mki_feed_cat( $query ) {
       if( is_feed() ) $query->set('category_name', 'YOUR_CAT_SLUG');

    FYI, I’m giving you the code only because it is so brief. For future reference, you’re more likely to to get help if you first make an effort yourself to solve your problem. There’s several examples in the reference very close to this. You could have figured this out. Maybe you make a mistake and it doesn’t work. Now you can show you made a reasonable effort yourself and just need a quick pointer.

    That will get you much farther than asking for free turnkey coding service, and you’ll likely learn something along the way 🙂

    thank you but i am an accountant! I have come this far to understand how to ask coding questions 🙂 but i am getting better slowly slowly!

    I will give this a go 😉

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Main RSS Feed – Show only posts from one category’ is closed to new replies.