Themes and automatic_feed_links

Since WordPress 2.8, there is the function automatic_feed_links() in the function.php. Which writes the link elements for the RSS protocols in the header of the document. The advantage of this feature is, you do not need to worry about whether a change comes in the Feed-protocoll in a new version of WordPress, removed or a new one is added.


If we develop a theme for the general public, you have 2 options. You use automatic_feed_links() and the theme does not work with WordPress prior to version 2.8, or you do not use this function and write the links as before, in your header.php.

I also have a 3rd alternative ;).

if (function_exists('automatic_feed_links')) {
    automatic_feed_links();
} else {
    add_action('wp_head', 'wpe_feed_links', 2);
}

function wpe_feed_links() {
    echo '<link rel="alternate" type="application/rss+xml" title="'. get_bloginfo('name').' RSS Feed" href="'. get_bloginfo('rss2_url').'" />';
    echo '<link rel="alternate" type="application/atom+xml" title="'. get_bloginfo('name').' Atom Feed" href="'. get_bloginfo('atom_url').'" />';
    echo '<link rel="alternate" type="application/rss+xml" title="'. get_bloginfo('name').' '. __('The latest comments to all posts in RSS').'" href="'. get_bloginfo('comments_rss2_url').'" />';
}

First we look if the function automatic_feed_links() exists. If not (prior to WP 2.8), we use the hook wp_head and write the links in the header of the page. Thus we don't need to adjust the header.php anymore.

Comments are closed.

2 comments

  1. Jacob Fiint

    Do you have any plans to release your WP Engineer theme? The theme that was currently used in this blog? 🙂

    I love how the theme was constructed. It's simple, yet elegant. 🙂

  2. Michael

    Thanks Jacob!

    We are lucky too with the design, so no plans at the moment. Maybe later. 😉