Using WordPress ‘post_comments_feed_link()’ PHP function

The post_comments_feed_link() WordPress PHP function displays the comment feed link for a post.

Usage

post_comments_feed_link( $link_text, $post_id, $feed );

Example:

post_comments_feed_link( 'View Comments', 42, 'rss2' );

Parameters

  • $link_text (string) – Optional. Descriptive link text. Default ‘Comments Feed’.
  • $post_id (int) – Optional. Post ID. Default is the ID of the global $post.
  • $feed (string) – Optional. Feed type. Possible values include ‘rss2’, ‘atom’. Default is the value of get_default_feed().

More information

See WordPress Developer Resources: post_comments_feed_link()

Examples

Basic usage

Display the comment feed link with the default text and feed type for the current post.

post_comments_feed_link();

Display the comment feed link with custom text for the current post.

post_comments_feed_link( 'View All Comments' );

Specific post ID

Display the comment feed link for a specific post ID.

post_comments_feed_link( 'Comments Feed', 42 );

Custom feed type

Display the comment feed link with a custom feed type (e.g., ‘atom’) for the current post.

post_comments_feed_link( 'Atom Comments Feed', '', 'atom' );

Combining custom parameters

Display the comment feed link with custom text, specific post ID, and custom feed type.

post_comments_feed_link( 'View Comments', 42, 'rss2' );