Displays the links to the general feeds.
Parameters
$args
arrayoptional- Optional arguments.
Default:
array()
Source
function feed_links( $args = array() ) {
if ( ! current_theme_supports( 'automatic-feed-links' ) ) {
return;
}
$defaults = array(
/* translators: Separator between site name and feed type in feed links. */
'separator' => _x( '»', 'feed link' ),
/* translators: 1: Site title, 2: Separator (raquo). */
'feedtitle' => __( '%1$s %2$s Feed' ),
/* translators: 1: Site title, 2: Separator (raquo). */
'comstitle' => __( '%1$s %2$s Comments Feed' ),
);
$args = wp_parse_args( $args, $defaults );
/**
* Filters the feed links arguments.
*
* @since 6.7.0
*
* @param array $args An array of feed links arguments.
*/
$args = apply_filters( 'feed_links_args', $args );
/**
* 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 ) ) {
printf(
'<link rel="alternate" type="%s" title="%s" href="%s" />' . "\n",
feed_content_type(),
esc_attr( sprintf( $args['feedtitle'], get_bloginfo( 'name' ), $args['separator'] ) ),
esc_url( get_feed_link() )
);
}
/**
* 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 ) ) {
printf(
'<link rel="alternate" type="%s" title="%s" href="%s" />' . "\n",
feed_content_type(),
esc_attr( sprintf( $args['comstitle'], get_bloginfo( 'name' ), $args['separator'] ) ),
esc_url( get_feed_link( 'comments_' . get_default_feed() ) )
);
}
}
Hooks
- apply_filters( ‘feed_links_args’,
array $args ) Filters the feed links arguments.
- apply_filters( ‘feed_links_show_comments_feed’,
bool $show ) Filters whether to display the comments feed link.
- apply_filters( ‘feed_links_show_posts_feed’,
bool $show ) Filters whether to display the posts feed link.
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.