feed_links() WordPress Function

The feed_links() function enables the display of links to RSS feeds on a WordPress site. This function can be used to link to both feeds for posts and comments. By default, WordPress includes links to RSS feeds for the site content and comments in the site head. These links can be customized with the feed_links() function.

feed_links( array $args = array() ) #

Display the links to the general feeds.


Parameters

$args

(array)(Optional)arguments.

Default value: array()


Top ↑

Source

File: wp-includes/general-template.php

3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
function feed_links( $args = array() ) {
    if ( ! current_theme_supports( 'automatic-feed-links' ) ) {
        return;
    }
 
    $defaults = array(
        /* translators: Separator between blog name and feed type in feed links. */
        'separator' => _x( '»', 'feed link' ),
        /* translators: 1: Blog title, 2: Separator (raquo). */
        'feedtitle' => __( '%1$s %2$s Feed' ),
        /* translators: 1: Blog title, 2: Separator (raquo). */
        'comstitle' => __( '%1$s %2$s Comments Feed' ),
    );
 
    $args = wp_parse_args( $args, $defaults );
 
    /**
     * Filters whether to display the posts feed link.
     *
     * @since 4.4.0
     *
     * @param bool $show Whether to display the posts feed link. Default true.
     */
    if ( apply_filters( 'feed_links_show_posts_feed', true ) ) {
        echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['feedtitle'], get_bloginfo( 'name' ), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link() ) . "\" />\n";
    }
 
    /**
     * Filters whether to display the comments feed link.
     *
     * @since 4.4.0
     *
     * @param bool $show Whether to display the comments feed link. Default true.
     */
    if ( apply_filters( 'feed_links_show_comments_feed', true ) ) {
        echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['comstitle'], get_bloginfo( 'name' ), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link( 'comments_' . get_default_feed() ) ) . "\" />\n";
    }
}


Top ↑

Changelog

Changelog
VersionDescription
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More