By default WordPress uses its own feed system, but that is basic and you may want something better, like FeedBurner, which is owned by Google. It’s a great alternative and includes a great amount of features.So, instead of using WordPress feeds, let’s redirect the visitor to your FeedBurner feed, using one of the following methods:

Custom Theme Function

Add the following to your theme’s functions.php file:

// Replaces the WordPress Feeds with a FeedBurner feed function redirectrssfeedtofeedburner( $output, $feed ) { if ( strpos( $output, ‘comments’ ) ) return $output; return escurl( ‘http://feeds.feedburner.com/BrandonHimpfen’ ); } addaction( ‘feedlink’, ‘redirectrssfeedto_feedburner’, 10, 2 );

Make sure you replace my FeedBurner URL with your Feed Burner URL – this is located in line 5.

What this function does, is replace the WordPress feed with a FeedBurner feed.

Once you add it to your theme’s functions.php file, go to your website or refresh your website and view the source code. You’ll notice the following:

Is replaced with a FeedBurner link:

Replace WordPress sub-Feeds

What do I mean by WordPress sub-feeds? Feeds that are not the main feeds, like tags, categories, taxonomy, authors, and search. This is useful if you have setup a custom FeedBurner URL for these feeds, i.e. a category that has a different FeedBurner URL.

We can do this by modifying the above code snippet like so:

// Replaces the Bootstrap Category Feed with a FeedBurner Feed function bootstrapcatfeedburnerfeed( $output ) { if ( strpos( $output, ‘/bootstrap/feed’ ) ) return $output = escurl( ‘http://feeds.feedburner.com/Bootstrap’ ); else return $output; } addfilter( ‘categoryfeedlink’, ‘bootstrapcatfeedburnerfeed’ );

What you need to do, is look for /bootstrap/feed on line 3 and replace it with the URL (minus your domain name) of the feed.

Next, you’ll need to modify the add_filter with the appropriate action hook. Use one of the following:

addfilter( ‘tagfeedlink’, ‘functionname’ ); // for tag feeds addfilter( ‘categoryfeedlink’, ‘functionname’ ); // for category feeds addfilter( ‘taxonomyfeedlink’, ‘functionname’ ); // for taxonomy feeds addfilter( ‘authorfeedlink’, ‘functionname’ ); // for author feeds addfilter( ‘searchfeedlink’,’functionname’ ); // for search feeds

Make sure you replace function_name with the name of the function, which is found on line 1, right after the word function and right before the brackets ().

What You Should Note

What the custom functions do not do is force a redirection. What do I mean? If a visitor or bot directly goes to the WordPress feed URL, the feed will still display. It will not redirect to the FeedBurner URL. You may not want this, so let’s use .htaccess to force a redirect to FeedBurner. See below.

Using .htaccess to Redirect the Visitor

Now, you can also redirect the visitor to your FeedBurner URL with .htaccess like so:

RewriteEngine on RewriteCond %{HTTPUSERAGENT} !FeedBurner [NC] RewriteCond %{HTTPUSERAGENT} !FeedValidator [NC] RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://feeds.feedburner.com/BrandonHimpfen [R=302,NC,L]

Make sure you replace my FeedBurner URL with your FeedBurner URL – this is located in line 5.

What this .htaccess code snippet tells your server is, “Hey, if the feed URL is not using the FeedBurner service, redirect the non-FeedBurner URL to your specified FeedBurner URL.

With this .htaccess code snippet, you also do not necessarily need the custom function, as any visitor that goes to the WordPress feed URL will redirect to the FeedBurner feed URL.