The Easy Way to Connect FeedBurner to WordPress

The Easy Way to Connect FeedBurner to WordPress

Hello, this is Pavel! In this article, I want to describe a non-standard but very simple way to connect the FeedBurner service to the WordPress engine. By the way, I use this exact method on my own site.

“If you're lazy — build your own bike.” That’s been my motto while working with WP lately. I didn’t bother searching for a suitable plugin again — instead, I went to the documentation to see how to override the default feed. Unfortunately, I couldn’t find anything useful. So I had to go another route — disable the current feed and hook in the new one using wp_head.

Now, let’s go step by step and in more detail.

In previous articles, I’ve mentioned more than once that I use a child theme based on “twentytwelve” for my blog. And in this case, it required a bit of extra work when connecting FeedBurner. First, I had to disable the feed added in the parent theme’s twentytwelve_setup(). This can be done using the following code:

if(function_exists('wp2fl_ext_after_setup_themep') == FALSE):
	function wp2fl_ext_after_setup_themep()
	{
		remove_theme_support('automatic-feed-links');
	}
	add_action('after_setup_theme', 'wp2fl_ext_after_setup_themep',20);
endif;

Here, the after_setup_theme hook and the remove_theme_support('automatic-feed-links'); function help us out.

The after_setup_theme hook is triggered every time a page loads, right after the theme has been initialized.

The function remove_theme_support('automatic-feed-links'); simply removes the previously registered feed links.

If you skip this step and add your own feeds, you’ll end up with duplicates — and readers may be confused when subscribing, since there will be not two, but four feeds.

Next, using the following code, we add our FeedBurner RSS feed and also a comments feed:

if(function_exists('wp2fl_ext_wp_head') == FALSE):
	function wp2fl_ext_wp_head()
	{
		echo '<link rel="alternate" type="application/rss+xml" title="'.get_bloginfo( 'name', 'display' ).' &raquo; Feed" href="http://feeds.feedburner.com/wp2fl" />'."n";
		echo '<link rel="alternate" type="application/rss+xml" title="'.get_bloginfo( 'name', 'display' ).' &raquo; Comments Feed" href="'.get_bloginfo('comments_rss2_url').'" />'."n";
	}
	add_action('wp_head', 'wp2fl_ext_wp_head',5);
endif;

As you can see, it’s all very simple. And you don’t need any plugins 🙂

Have a great day and productive work!

Posts on similar topics

Are you having problems with your WordPress site? Do you need additional functionality? A custom plugin or a new page?
Then write to me via the feedback form, and I will try to help you.

Write a comment

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