So, you’ve set up a Feedburner account, but you don’t know how to point your feeds to it correctly. The best method is to change this within your .htaccess file, but some bloggers might not be very comfortable fiddling with it or might not even be able to access it through FTP (depending on hosting environment).
What I’ll show you is a simple way to change all of your feed links without having to dig through a bunch of code in all of your theme and plugin files. This is also a great method for theme authors that allow users to input a custom feed URL through a theme settings page.
Before moving on, I do recommend using Perishable Press’ method of redirecting feeds through htaccess.
Using your theme’s functions.php to change feed links
The first thing we need to do is open our theme’s functions.php file.
Then, you need to open a set of PHP tags:
<?php
What we’ll do from this point is change our main feeds to point to our Feedburner account:
add_filter('feed_link','custom_feed_link', 1, 2);
function custom_feed_link($output, $feed) {
$feed_url = 'http://feeds.feedburner.com/justintadlock';
$feed_array = array('rss' => $feed_url, 'rss2' => $feed_url, 'atom' => $feed_url, 'rdf' => $feed_url, 'comments_rss2' => '');
$feed_array[$feed] = $feed_url;
$output = $feed_array[$feed];
return $output;
}
That points all of our main RSS and Atom feeds to Feedburner. However, you might not know that your author, category, tag, and search archives all have feeds associated with them. You can change those links as well.
add_filter('category_feed_link', 'other_feed_links');
add_filter('author_feed_link', 'other_feed_links');
add_filter('tag_feed_link','other_feed_links');
add_filter('search_feed_link','other_feed_links');
function other_feed_links($link) {
$link = 'http://feeds.feedburner.com/justintadlock';
return $link;
}
Don’t forget to close off your PHP:
?>
Final thoughts on feeds
As I’ve said, the htaccess method is the best way to ensure your feeds are being directed to the proper place. The method described above does nothing more than change the output of your feed links.
The most practical application of this is for theme authors to help their users by adding in this option on the theme settings page.
And yes, I know there are plugins that handle feeds, but I don’t much see a point in using a plugin for simple tasks.
Also, check out this great collection of 10 RSS tips for WordPress by Jean-Baptiste Jung.



[...] Change your feed links without using htaccess (tags: WordPress tips rss feed feedburner) [...]
Thank you for this, Justin. One thing that I never see addressed in RSS + Feedburner + WP tips is the ability to preserve individual category feeds when redirecting to Feedburner. In other words, a feedburner link for each category feed. Is that even possible? You write the best tutorials around these days, and I hope you find this interesting enough to take on.
@Justin: This is a great addition to the available Feedburner redirection methods, and the first I have seen for using PHP. I am looking forward to trying this technique and testing the various redirect possibilities. Thanks for sharing it with us, and thanks for mentioning my article as well!
@Erin: Custom category and tag feeds are certainly possible. For PHP, use the (second) method described in this article and replace the
$linkvalue with that of your category feed. For additional categories, tags, and other feeds, simply extrapolate either method with the desired Feedburner URLs. For HTAccess, the method(s) described in this article will do everything you need.Erin
You can definitely do it per category, but I really suggest using
.htaccessfor that. If you’re just looking to change it on category pages themselves, you can try out using conditional tags.Jeff
I was looking for a PHP method myself because I wanted to use it within my themes, but I couldn’t find anything. So, I just had to dig around a bit in the WP code.
I personally use your
.htaccessredirection method here on this site.Hey, nice tips, even I don’t know much about coding but with this I think I can do it man.
[...] How to change your feed links without using htaccess – So, you’ve set up a Feedburner account, but you don’t know how to point your feeds to it correctly. The best method is to change this within… [...]
What if you don’t use a theme, but rather have created your own theme? I’m having a hard time doing this on my website, finding the right solution. I have the “semi-pretty” permalinks activated (index.php/date/postname) as my host is through a friend on a Windows server, using IIS (and therefore no .htaccess).
I can’t seem to get feedburner to validate any method I try as .xml.
I’m thinking that changing this functions.php won’t do anything as I don’t really use a theme. Where is functions.php referenced? Should I move this file to the root of my site?
This works great with wordpress 2.7. Thanks!!
[...] ajouter une fonction dans le fichier functions.php de votre thème. Le code est expliqué sur http://justintadlock.com/ (en [...]
Thank you so much for this solution, Justin. I tried .htaccess with no success and I was so glad to find this. You really made my day!