Version 3.0 of WordPress is due out soon, and theme developers are getting geared up to implement the new features. The new menu system has received much attention as it’s one of the biggest changes, besides the merge of the WPMU code, that most users will use.
One feature that I didn’t know exists until now is automatic feed links which will output all the different feed links to current page the users is on to the header. It was added in 2.8 but has been changed how it works for 3.0. For example on a single post page the main blog feed, and the single post comment feed links are added to the header allowing a user to easily subscribe to the either feed. Another is on a category archive page the feed for the main blog, as well as the feed for all posts in that category are added. So I’ve got this feature added to my Techozoic theme but to maintain backwards compatibility I though I would share the simple function I came up with.
To enable the automatic feed links it’s very simple, just use the add_theme_support function with the automatic-feed-links as the parameter like this into your functions.php.
[php light=”true”]
if(function_exists(‘add_theme_support’)) {
add_theme_support(‘automatic-feed-links’);
//WP Auto Feed Links
}
[/php]
It’s critical to test if a function exists before calling it to prevent errors.
[php]
function remove_feed_link(){
global $wp_version;
$default_feed_link = ‘<link rel="alternate" type="application/rss+xml" title="’. get_bloginfo(‘name’). ‘ RSS Feed" href="’. get_bloginfo(‘rss2_url’) .’" />’;
if($wp_version < 3){
if(function_exists(automatic_feed_links)){
$output .= automatic_feed_links();
} else {
$output .= $default_feed_link;
}
}
echo $output;
}
add_action(‘wp_head’, ‘remove_feed_link’);
[/php]
Most theme authors include the default RSS feed in the header of their themes, but the new feature requires those links to be removed to work correctly. The trick to the automatic-feed-links is it’s a new 3.0 feature but the add_theme_support has exists since 2.9 so you can’t use the same check to disable your old feed links from the header. But what you can do is to check if the check the wp_version variable is less than 3, and if it is use either automatic_feed_links function or echo your own RSS link. Then you just add your function to be called with wp_head using add_action.
Futher Reference:
add_theme_support Codex Article

By Towfiq I August 10, 2010 - 8:34 am
Thanks for the use of new automatic-feed-links
By abdussamad November 4, 2010 - 10:23 am
Your code appears to be incorrect. If the wordpress version is greater than or equal to 3.0 your code will still display the default link code instead of using the output of automatic_feed_links()
By Ian V. December 1, 2010 - 10:49 pm
I’m not sure if that’s causing my site to display comments rss instead of contents feed. I noticed it when I commented from a blog using a commentluv plugin. When I submitted by blog into a blog directory site, it’s also displaying comments feed instead of contents. You can check here http://www.topblogs.com.ph/details/22925.html
By Joshua January 25, 2011 - 9:33 pm
Thanks! I found your post in a Google search. I was having an issue with getting a 404 on my comment feed, I guess because I don’t have comments allowed on my site at the moment so there was nothing to show. I used what I learned here to remove the comment feed from my header while keeping the main feed.
By Grant May 26, 2011 - 3:46 am
Great article, good thing to learn a little about WordPress theme developer.
By Custom Wordpress RSS feeds and Feedburner : withoutnations : Mark Mitchell July 17, 2011 - 1:10 pm
[…] your theme requires backwards compatibility with WordPress before 3.0, have a look at Jeremy Clark‘s […]
By Arina September 23, 2011 - 1:20 pm
Thanks. I just applied to my site, and it actually works!
By Clara September 26, 2011 - 11:41 pm
Thanks for sharing the automatic feed links code. Now I know what to do.