Spicing up you’re wordpress RSS feed

by adam

Here’s a nifty little function you can add to you’re theme’s functions.php
to append the post category link in you’re rss feed, but the same technique can be applied to add just about anything. This can be especially useful if some sites are scraping you’re content from you’re rss feed and you want to include a link back. It utilizes the ‘the_excerpt_rss’ and ‘the_content_rss’ hooks depending on how you’re rss feed is configured.

//Add a feed link back to category level page
function feed_link($content) { global $post;

foreach((get_the_category()) as $category) {

if ($category->category_parent == 0) {
$cat_name = $category->name;
$cat_ID = $category->cat_ID;
$link = get_category_link( $cat_ID );

break;
}
}
$content = $content.'<br /><a href="'.$link.'">More '.$cat_name.'  posts</a>';

return $content;
}
add_filter('the_excerpt_rss','feed_link');
add_filter('the_content_rss','feed_link');