4 require_once('wp-config.php');
5 wp('feed=rss2&withcomments=1');
8 header('Content-type: text/xml;charset=' . get_settings('blog_charset'), true);
10 echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>';
12 <!-- generator="wordpress/<?php echo $wp_version ?>" -->
14 xmlns:content="http://purl.org/rss/1.0/modules/content/">
19 while (have_posts()) : the_post();
23 <title><?php if (is_single() || is_page() ) { printf(__('Comments on: %s'), get_the_title_rss()); } else { printf(__('Comments for %s'), get_bloginfo_rss("name")); } ?></title>
24 <link><?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?></link>
25 <description><?php bloginfo_rss("description") ?></description>
26 <pubDate><?php echo gmdate('r'); ?></pubDate>
27 <generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator>
30 if (is_single() || is_page()) {
31 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
32 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
33 $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
34 LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id'
35 AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status IN ('publish', 'static', 'object')
36 AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "'
37 ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss') );
38 } else { // if no post id passed in, we'll just ue the last 10 comments.
39 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
40 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
41 $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
42 LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status IN ('publish', 'static', 'object')
43 AND $wpdb->comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "'
44 ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss') );
46 // this line is WordPress' motor, do not delete it.
48 foreach ($comments as $comment) {
49 // Some plugins may need to know the metadata
50 // associated with this comment's post:
51 get_post_custom($comment->comment_post_ID);
54 <title><?php if ( ! (is_single() || is_page()) ) {
55 $title = get_the_title($comment->comment_post_ID);
56 $title = apply_filters('the_title', $title);
57 $title = apply_filters('the_title_rss', $title);
58 printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss());
60 printf(__('by: %s'), get_comment_author_rss());
62 <link><?php comment_link() ?></link>
63 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate>
64 <guid><?php comment_link() ?></guid>
66 if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {
68 <description><?php _e('Protected Comments: Please enter your password to view comments.'); ?></description>
69 <content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>
73 <description><?php comment_text_rss() ?></description>
74 <content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>
76 } // close check for password