5 RSS Feed Tricks You Should Know
If you’re serious about blogging, you’re probably no stranger to RSS (Really Simple Syndication). As the most widespread and easy way to distribute your content to faithful readers, it’s a powerful tool that has become the standard for content syndication.
Many bloggers, unfortunately, never consider how their content will appear in an RSS feed. With a bit of extra code here and there, you can easily optimize your RSS presence and make it easier for readers to share your material with the world. Here are five of the most important things you can do to show your RSS feed some love right now.
1. Include a Thumbnail for Each Post
Ever since WordPress added handy thumbnail functionality last year, theme developers have been making use of it. However, RSS feeds won’t use thumbnails without a little extra push from you. Paste the following code into your theme’s “functions.php” file:
// show post thumbnails in feeds
function diw_post_thumbnail_feeds($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<div>' . get_the_post_thumbnail($post->ID) .'</div>' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'diw_post_thumbnail_feeds');
add_filter('the_content_feed', 'diw_post_thumbnail_feeds');
Save the changes, and your feeds will now display each post’s thumbnail before the post content. If you want the content to wrap around the thumbnail, simply remove the <div> and </div> tags from Line 05 of the above code.
2. Create a Delay Between Publication and Appearance in RSS
We’ve all done it: You craft a great post, hit publish, and immediately realize you made a mistake that needs to be corrected. You can, of course, always go back and edit it, but if your blog automatically makes each new post immediately available in RSS, then the flawed version will be the one that your readers see.
To avoid this, let’s add a 5-minute delay between when your post is published and when it becomes available in RSS. Go back to the “function.php” file and add the following code:
function publish_later_on_feed($where) {
global $wpdb;
if ( is_feed() ) {
// timestamp in WP-format
$now = gmdate('Y-m-d H:i:s');
// value for wait; + device
$wait = '5'; // integer
// http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
$device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
// add SQL-sytax to default $where
$where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
}
return $where;
}
add_filter('posts_where', 'publish_later_on_feed');
To change the length of the delay, just switch the value of the $wait variable on Line 09. Save the changes, and you’re finished.
Incidentally, all TheTheFly themes include this important little detail.
3. Exclude Certain Post Categories from Your Feed
If one or more of the categories you use for publishing posts has nothing to do with the rest of your content, then you probably don’t want it published in the RSS feed. Excluding such categories is only a code snippet away.
First, find the numeric ID of the category you want to include. Not sure what that ID is? Here’s how to find it.
Now paste the following code into “functions.php”, remembering to change the category ID appropriately:
function myFilter($query) {
if ($query->is_feed) {
$query->set('cat','-5'); //Don't forget to change the category ID =^o^=
}
return $query;
}
add_filter('pre_get_posts','myFilter');
Save the changes, and the category will be excluded from your RSS feed from now on.
All of our themes also include this useful function; it’s merely up to you to edit the category ID as you see fit.
4. Redirect WordPress Feeds to FeedBurner
FeedBurner is a fantastic tool for bloggers. If you’re a blogger and haven’t already checked it out, you owe it to yourself to find out if it’s right for you. However, if some readers have already subscribed to your original WordPress RSS feed and you want to start with Feedburner, you don’t want to send them to two different places for your content. Plus, if you change themes often, you won’t enjoy updating all the code over and over to make sure WordPress uses Feedburner as your RSS engine.
A simple server redirect is your solution.
First, back up your .htaccess file, which is located in your site’s root directory.
Next, add the following code to the file:
# temp redirect wordpress content feeds to feedburner
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !FeedBurner [NC]
RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://feeds.feedburner.com/wprecipes [R=302,NC,L]
</IfModule>
Save it, and you’re done!
This one is also incorporated into all TheTheFly Themes. (We practice what we preach.)
5. Insert Ads Into Your RSS Feed
Time to make some money. Many blog owners nowadays insert ads into RSS feeds to monetize their blogs. Unfortunately, with Feedburner you can only insert AdSense ads and you’ll need at least 500 subscribers just to get in the door.
The good news is that inserting other kinds of ads on your own isn’t a complicated process.
Just paste the following code into your “functions.php” file:
function insertAds($content) {
$content = $content.'<hr /><a href="http://www.wprecipes.com">Have you visited WpRecipes today?</a><hr />';
return $content;
}
add_filter('the_excerpt_rss', 'insertAds');
add_filter('the_content_rss', 'insertAds');
You can easily see in Line 03 of this code snippet where to insert your own URL and link text. Do that, save the file, and congratulations: You’re now an advertiser.


This is a really useful post for non-coder like me – how about one on .htaccess files ?
Thanks
James