New the_comments_link_rss() function, with comments_link_rss filter (1 post)

  1. nickforge
    Posted 7 years ago #

    I would like to have the option to disable the <comments> tag in my RSS feeds. For now, the only way to do that is to hack /wordpress/wp-includes/feed-rss2.php (for RSS2) by removing the line that says:

    <comments><?php comments_link(); ?></comments>

    A simple method to allow a plugin to disable the <comments> tag would be to create a new function, the_comments_link_rss(). Instead of the above, you would use the following in feed-rss2.php:

    <?php the_comments_link_rss() ?>

    The actual function would be as simple as something like this:

    the_comments_link_rss() {
    	$the_comment = '<comment>' . comments_link() . '</comment>';
    	return apply_filters('the_comments_link_rss', $the_comment);

    That way, a plugin would simply have to add a 'the_comments_link_rss' filter, and have it return an empty string, disabling the comments field. If feed templates don't get added to WP, this seems like a very simple way to add this functionality.

Topic Closed

This topic has been closed to new replies.

About this Topic