comment_feed.php :
Download comment_feed.php
<?php
/* Comment feed */
$last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
make_cacheable($last_modified, 60*60*3);/* make cacheable in browsers for 3 hours & send 'Not modified' (304) header if not modified. */
header('Content-Type: text/xml;charset=' . get_option('blog_charset'), true);
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
>
<channel>
<title><?php echo 'Comments : ', get_wp_title_rss(''), ' - ', get_bloginfo( 'name' );?></title>
<atom:link href="http://<?php echo $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']; ?>" rel="self" type="application/rss+xml" />
<link><?php the_permalink_rss(); ?></link>
<description><?php the_excerpt_rss(); ?></description>
<pubDate><?php echo gmdate('r'); ?></pubDate>
<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
<image>
<url>http://media.example.com/logo.png</url>
<title><?php echo 'Comments : ', get_wp_title_rss(''), ' - ', get_bloginfo( 'name' );?></title>
<link><?php the_permalink_rss(); ?></link>
<width>50</width>
<height>50</height>
<description><?php the_excerpt_rss(); ?></description>
</image>
<?php do_action('commentsrss2_head');
$q = "SELECT comment_ID, comment_author, comment_date_gmt, comment_content FROM $wpdb->comments WHERE comment_post_ID = $post->ID AND comment_approved = 1 ORDER BY comment_date DESC LIMIT 10";
$comments = $wpdb->get_results($q);
foreach($comments as $comment)
{ $comment->comment_ID; $date = mysql2date('D, d M Y H:i:s +0000', $comment->comment_date_gmt); ?>
<item>
<title><?php echo $comment->comment_author; ?></title>
<link><?php trailingslashit(the_permalink_rss()); ?>#comments</link>
<pubDate><?php echo $date; ?></pubDate>
<dc:creator><?php echo $comment->comment_author; ?></dc:creator>
<guid isPermaLink="false"><?php trailingslashit(the_permalink_rss()); ?>#comment-<?php echo $comment->comment_ID; ?></guid>
<description><![CDATA[<?php echo strip_tags(substr($comment->comment_content, 0, 40)); ?>]]></description>
<content:encoded><![CDATA[<?php echo $comment->comment_content; ?>]]></content:encoded>
</item>
<?php } ?>
</channel>
</rss>
This entry was posted on Wednesday, December 2nd, 2009 at 1:27 am and modified by WebMaster View on Thursday, March 4th, 2010 at 5:09 pm. You can follow any responses to this entry through the RSS 2.0 feed.
Responses are currently closed, but you can trackback from your own site.
Very useful function. I was searching it for long time. Thanks
May 17, 2010 at 11:51 am cherthala friends
Thank you so much for sharing this. This is a really great source which can improve websites. Thanks again!
April 16, 2010 at 8:26 am Video Avatar
I was searching for this and got it here.. great share
February 22, 2010 at 7:28 pm amandkumar
MOrning mr Syam!
I want to thank you for this great webpage it has helped me alot and i don have to have as many sleepless nights!
Thanx and i have now bookmarked this page!
February 22, 2010 at 11:20 am Vuxenleksaker