Exclude a category in WordPress RSS feed


A regular visitor asked us how he can exclude a category posts appearing in Feedburner feed. To exclude a category posts appearing in Feedburner, we can not from Feedburner settings, we have to control the source : that is the blog feed.

 

Follow these instructions to exclude a category posts appearing in the Feed:

Write down the category ID you want to exclude from the feed. Open notepad, write the category name save as exclude a category (or something like that); otherwise it is difficult to remember.

 

To find the category you want to exclude, Go to Posts > Categories and hover your mouse over the category you want to exclude. You will see something like this in your lower pane of :

 

Exclude a category in WordPress RSS feed

 

We have marked the category ID above.


 

Editing the functions. file to exclude a category

 

We have to edit the file named functions.php of your theme file to exclude a category. You can use Notepad or Gedit (our choice) to edit :

 

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

 

Obviously, you have to the red text, which is our category ID in this example to exclude a category you want. Save the changes to the file. You can use comma to separate more categories to exclude.
Signature


If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.
About Abhishek

Abhishek Ghosh is an Orthopedic Surgeon, Inventor with 216 Patents, Current editor of The Customize Windows Media Group. You can follow and know more about Dr. +Abhishek Ghosh on Google Plus and follow on Twitter as @AbhishekCTRL.

Trackbacks

  1. Exclude a category in Wordpress RSS feed « Wordpress Tricks says:

    [...] Exclude a category in WordPress RSS feed [...]

Speak Your Mind

*