How to Change the Default URL for RSS Feed in WordPress

The default RSS URL for WordPress is http://your-site.com/feed/. Theme makers and developers use the default RSS URL every where on a theme.

This default URL is retrieved by using the WordPress template tag bloginfo(‘rss_url’).

But, what if you use FeedBurner or a similar service? How do you tell WordPress, its themes, and its plugins to show your own custom RSS link instead of the default?

Here’s how. Paste the following code into the functions.php file of your theme:

function my_rss_link($output, $show)
{
	if (in_array($show, array('rss_url', 'rss2_url', 'rss', 'rss2', '')))
		$output = 'http://feeds.feedburner.com/winkpress';
 
	return $output;
}
add_filter('bloginfo_url', 'my_rss_link', 10, 2);
add_filter('feed_link', 'my_rss_link', 10, 2);

That’s it.

Now whenever bloginfo(‘rss_url’) or bloginfo(‘rss2_url’) is called, it’ll show your custom RSS feed link. Don’t forget to replace my RSS URL with your own above.

Some people may still be using your old RSS link or they may try to manually add /feed/ to your site’s domain. You can have this URL redirect to your custom RSS feed.

Paste the following code in your .htaccess file:

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

3 comments

  1. it works fine !!

  2. Thanks, this was just what I was looking for.

  3. Thank you!! That worked like a charm :)

Leave a comment

Your email address will not be published. Required fields are marked *

*

Read this to make your comment cool.