If you want to add RSS auto-discovery to your WordPress site, you could manually add the link tags to your theme’s header.php
file in-between the opening <head>
and closing </head>
tags:
<link
rel="alternate"
type="application/rss+xml"
title="<?php bloginfo( 'name' ) ?> » Feed"
href="<?php bloginfo( 'rss2_url' ) ?>"
/>
<link
rel="alternate"
type="application/rss+xml"
title="<?php bloginfo( 'name' ) ?> » Comments Feed"
href="<?php bloginfo( 'comments_rss2_url' ) ?>"
/>
Or if you can’t edit header.php
, you could add a hook to your functions.php
file which achieves the same effect:
add_action( 'wp_head', function () {
?>
<link
rel="alternate"
type="application/rss+xml"
title="<?php bloginfo( 'name' ) ?> » Feed"
href="<?php bloginfo( 'rss2_url' ) ?>"
/>
<link
rel="alternate"
type="application/rss+xml"
title="<?php bloginfo( 'name' ) ?> » Comments Feed"
href="<?php bloginfo( 'comments_rss2_url' ) ?>"
/>
<?php
} );
However, there’s an even easier way. Instead constructing the link tags manually, all you need to do is add one line of code to your theme’s functions.php
file:
add_theme_support( 'automatic-feed-links' );
This will automatically construct & inject the link tags into your theme’s head. Perfect!