• Home
  • Blog
  • Contact Us
  • Home
  • Blog
  • Contact Us

How To Remove Specific Category Posts From A WordPress RSS Feed

Last Updated: 14 June 2013 By Mike Haydon

I recently noticed on one of my sites that wordpress posts from a particular category were appearing in the site’s rss feed. That category was only meant for people who had the specific url. Not secure, I know, but we weren’t too worried if the urls got passed around. However, we didn’t want them in the rss feed.

After hunting around for a bit, I came across this from Ash Point Lane. The code is slightly different from Bruce’s because his seems to have corrupted slightly when he posted it. The problem in his php is the > which should be > and if you use the code as he has it, you’ll have to ftp into the functions.php file to fix it :(. Lesson learned.

So, add this code to your functions.php file. Change the number from 5 to the ID of the category you want to exclude.

function myFilter($query) {
if ($query->is_feed) {
$query->set(‘cat’,’-5‘);
}
return $query;
}
add_filter(‘pre_get_posts’,’myFilter’);

And voila! It should be all sorted.

In case you aren’t sure how to find the category ID… go to the Categories section in your wordpress admin area (it’s under Posts). Hover your mouse over the category you want and notice in the status bar at the bottom of your browser there should be a url which ends/contains

tag_ID=5

in that case, your category ID is 5.

Filed Under: Wordpress
Originally Posted: 1 November 2010

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Web Design

marketing banner

Want to learn how to build your own websites? Check out the course we jointly developed here.

Recent Posts

  • Moving Wordpress Without Plugins
  • Redirection Problem When Installing Wordpress
  • Edit The Default Wordpress RSS Widget
  • Best Wordpress Spam Filtering Plugin
  • Optimize Your Wordpress Site For Mobile
  • Wordpress Delete Post Revisions
  • Add Twitter Follower Count To A Wordpress Page

How Can We Help You?

  • Website Design Service
  • Google Penalty Recovery Service
  • Search Engine Optimization Service

Categories

  • Online Marketing
  • SEO
  • Social Media
  • Website Design
  • Wordpress

At A Glance

  • Ranking
  • Website Design
  • WordPress
  • Social Media
  • Contact
  • Google Penalties
  • Earnings Disclosure
  • Privacy Policy

Contact Us

Local SEO Perth

Contact Us Here

Copyright © 2023