For ages, theme authors have been adding code like this to their theme’s header.php files:

<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />

No need for that any more. Remove that stuff, make sure you’ve got the wp_head() call in the header (like you should anyway), then add this to the theme’s functions.php file instead:

add_theme_support( 'automatic-feed-links' );

This automatically adds the relevant feed links everywhere on the whole site. Standard feed, comments links, category and tag archives, everything as it should be.

Shortlink:

14 Comments

  1. says:

    thx, great tip, been struggling with a lot of plugins to achieve this :-)

  2. says:

    Automatic feed links have been around since WP 2.8.

    Only the `add_theme_support( ‘automatic-feed-links’ );` bit is new.

  3. says:

    woowww.. simple tags thanks for share

  4. I needed to know about this,
    thanks for posting AND making it findable in one page search!

  5. [...] the <head> section of their pages. Now, WordPress 3.0 does it automatically for us. Check out Otto’s post for more [...]

  6. [...] the <head> section of their pages. Now, WordPress 3.0 does it automatically for us. Check out Otto’s post for more [...]

  7. [...] it opens up a wide variety of possibilities for customizing the background of your WordPress Theme.WordPress 3.0 Theme Tip: Feed Links – Otto on WordPress – Otto brings up another tip for WordPress Theme authors on how to add automatic feed links [...]

  8. [...] Otto on WordPress – add theme support automatic feed links [...]

  9. I have added the code to functions.php and the header is correct, but the feeds do not work. Anything else I might try? This is a wp ecommerce site. Thanks for the tips.

  10. says:

    I’m using this to generate automatic feed links, however I would like to disable the Global Comments Feed from appearing on EVERY page. Any suggestions?

Leave a Reply

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

Connect with Facebook

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Need to post PHP code? Wrap it in [php] and [/php] tags.