post_comments_feed_link() WordPress Function

The post_comments_feed_link() function allows you to display a link to the comments feed for a post. This is useful if you want to allow readers to subscribe to comments for a particular post.

post_comments_feed_link( string $link_text = '', int $post_id = '', string $feed = '' ) #

Displays the comment feed link for a post.


Description

Prints out the comment feed link for a post. Link text is placed in the anchor. If no link text is specified, default text is used. If no post ID is specified, the current post is used.


Top ↑

Parameters

$link_text

(string)(Optional) Descriptive link text. Default 'Comments Feed'.

Default value: ''

$post_id

(int)(Optional) Post ID. Default is the ID of the global $post.

Default value: ''

$feed

(string)(Optional) Feed type. Possible values include 'rss2', 'atom'. Default is the value of get_default_feed().

Default value: ''


Top ↑

Source

File: wp-includes/link-template.php

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 );
}


Top ↑

Changelog

Changelog
VersionDescription
2.5.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