post_comments_feed_link()WP 2.5.0

Outputs a link to the comments feed of the current post.

This function replaces the deprecated function comments_rss_link().

Hooks from the function

Returns

null.

Usage

<?php post_comments_feed_link( $link_text, $post_id, $feed ) ?>
$link_text(string)
Text of the link.
Default: 'link_text'
$post_id(int)
ID of the post for which to get the comments feed link.
Default: Current post
$feed(string)
Type of feed. Can be: atom, rdf, rss, rss2
Default: 'feed_type'

Examples

0

#1 Basic usage

<?php post_comments_feed_link() ?>

We get it:

<a href='URL page/feed'>Comment feed</a>

Changelog

Since 2.5.0 Introduced.

post_comments_feed_link() code WP 6.8.3

function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) {
	$url = get_post_comments_feed_link( $post_id, $feed );
	if ( empty( $link_text ) ) {
		$link_text = __( 'Comments Feed' );
	}

	$link = '<a href="' . esc_url( $url ) . '">' . $link_text . '</a>';
	/**
	 * Filters the post comment feed link anchor tag.
	 *
	 * @since 2.8.0
	 *
	 * @param string $link    The complete anchor tag for the comment feed link.
	 * @param int    $post_id Post ID.
	 * @param string $feed    The feed type. Possible values include 'rss2', 'atom',
	 *                        or an empty string for the default feed type.
	 */
	echo apply_filters( 'post_comments_feed_link_html', $link, $post_id, $feed );
}