Mark Zahra

Mark Zahra

Mark has been involved with WP RSS Aggregator for almost a decade, from running customer support to now leading RebelCode, the company behind the plugin. He has a passion for content and news, especially the concept of ethically sharing content to help each other grow.

Table of contents

RSS Tricks: How To Provide an RSS Feed for a Post’s Comments

This RSS trick isn’t much of a trick at all.

In fact it’s a function that’s built right into WordPress, but one that very few know of.

We’ve all come across a post that has a long (and I mean LONG) list of comments associated with it. Keeping track of these comments can be hard for the author, let alone the readers.

post-comments

The Fix

This is why WordPress offers the following function to provide an RSS feed specifically for the comments of a particular post.

<?php post_comments_feed_link('» Comments RSS Feed'); ?>

Now there are 2 ways that you can implement this:

    1. Place it inside your theme template in the appropriate location of your choice. (The code will generate the output, so there is no need for echo )
    2. Place it inside a handler of a hook such as wp_list_comments_args. This will output the link right before where the comments our output using the wp_list_comments function. The handler should look something like this:
function my_wp_list_comments_args( $args ) {
post_comments_feed_link( '» Comments RSS Feed' );

// Don't forget to return the original arguments
return $args;
}
add_filter( 'wp_list_comments_args', 'my_wp_list_comments_args' );

How It Works

Calling this line of code will simply call the post_comments_feed_link() function that provides an RSS feed for the comments of a specific post, making it easier for your readers to keep track of those many, many comments.

Source: WP Recipes

Article by

Article by

Share the Post:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Articles