How to modify your WordPress RSS Feed
I for myself really enjoy using WordPress as a Content Management System, since most of the time its really easy to adapt to my needs. I usually use the different categories on my sites to display the various sections of the sites. For example, kriesi.at uses the category “tutorials” to feed the resources page and the “portfolio” category to feed my online portfolio.
This is easily accomplished by using the query_posts() function of WordPress which i won’t discuss in detail since the documentations are pretty comprehensive.
The problem I recently encountered is that the WordPress generated rss feed must be modified as well, otherwise it will display every post in each category. A user subscribing to my blog feed doesn’t want to be bothered with portfolio entrys, so I searched for a way to exclude categories from the main feed. There are basically two solutions I could find:
- Exclude the Categories via URL
- Exclude the Categories through using a small function
Both ways are really simple:
If you want to exclude a category you first have to know the ID of course. In WordPress versions prior to 2.5 you could just get it in your admin panels “manage” -> “categories” section. Post 2.5 versions do not display the category ID anymore but you can get it by hovering over the category name and extracting it from the link URL. Its the cat_ID attribute.
Say you want to exclude category 20 you just append ?cat=-20 to your feed url.
Example:
- normal feed: https://kriesi.at/feed
- modified feed: https://kriesi.at/feed?cat=-20
- want to exclude more categories: https://kriesi.at/feed?cat=-20&cat=-21&cat=-22
Well these URLs are not what i would consider beautiful so you might use a service like feedburner to create a nice looking feed out of it. But beware, feedburner expects a slightly different syntax; insted of using ampersands you have to use commas:
So if you want to exclude a WordPress category from the Feedburner feed do it this way:
https://kriesi.at/feed?cat=-20,-21,-22
If you dont’t like this way of excluding you can use a small function instead. Just add the following code anywhere to your templates functions.php:
function my_cat_exclude($query) { if ($query->is_feed) { $query->set('cat','-20,-21,-22'); } return $query; } add_filter('pre_get_posts','my_cat_exclude');
This function will strip the categories you define out of your RSS Feed without the need of adjusting your url.
A clean and simple way but not as flexible as using URLs if you want to provide more than one feed.
Hope this helps you if you ever need to modify your feed.
Is it possible to exclude post thumbnails from the RSS feed using a similar function?
I’m using the atahualpa theme and I have the php for p75thumbnail inserted into my byline, so I figure I could just block the byline from displaying in the feed but am not sure how to do this.
Thoughts or guidance?
i always use feedburner to syndicate my blog posts to other subscribers.`;:
i always use feedburner to syndicate my blog posts to other subscribers.`:-
RSS feeds are really great because you are always updated with the latest news or blog posts.~’`
feed burner is very useful for blog owners because it is easy to syndicate feeds using feedburner **’
i always use feedburner for sharing the feeds of my blog, feedburner is really great.:,
RSS feeds are necessary for transmitting your blog updates to your readers or followers;*’
We have come a long way since this solution now. Twitter is really the new RSS.
i always syndicate feeds on my subcribers and of course feedburner is definitely a great help `.:
i think that RSS FEEDS should also be included on the list of the best inventions because it makes life easier for bloggers like us *;-