Changing WordPress Feed Links with Feedburner

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.

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.

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.

 

source: justintadlock

Artikel terkait:   Google Book Downloader for Mac

Isi Komentar

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

one × = six

This site uses Akismet to reduce spam. Learn how your comment data is processed.