Using WordPress ‘permalink_single_rss()’ PHP function

The permalink_single_rss() WordPress PHP function prints the permalink to the RSS feed.

Usage

permalink_single_rss();

Custom Example

function display_rss_feed_link() {
    echo 'RSS Feed: ';
    permalink_single_rss();
}

Output: RSS Feed: https://example.com/post-title/feed/

Parameters

  • $deprecated (string) Optional. Default: ''.

More information

See WordPress Developer Resources: permalink_single_rss()

Examples

Function: add_rss_feed_to_footer()
This function will add the RSS feed link to the footer of your WordPress site.

function add_rss_feed_to_footer() {
    echo '<div class="rss-feed-link">RSS Feed: ';
    permalink_single_rss();
    echo '</div>';
}
add_action('wp_footer', 'add_rss_feed_to_footer');

Function: rss_feed_button()
This function will create a custom RSS feed link button.

function rss_feed_button() {
    echo '<a href="';
    permalink_single_rss();
    echo '" class="rss-feed-button">Subscribe to RSS Feed</a>';
}

Function: rss_feed_widget()
This function will display the RSS feed link in a widget.

function rss_feed_widget() {
    echo '<div class="rss-feed-widget">RSS: ';
    permalink_single_rss();
    echo '</div>';
}

Function: add_rss_feed_to_menu()
This function will add the RSS feed link to the navigation menu.

function add_rss_feed_to_menu($items, $args) {
    if ($args->theme_location == 'primary') {
        $items .= '<li class="menu-item-rss"><a href="';
        permalink_single_rss();
        $items .= '">RSS Feed</a></li>';
    }
    return $items;
}
add_filter('wp_nav_menu_items', 'add_rss_feed_to_menu', 10, 2);

Display RSS feed link in post meta

Function: add_rss_feed_to_post_meta()
This function will display the RSS feed link in the post meta.

function add_rss_feed_to_post_meta() {
    echo 'Subscribe to comments: <a href="';
    permalink_single_rss();
    echo '">RSS Feed</a>';
}
add_action('genesis_entry_footer', 'add_rss_feed_to_post_meta');