How to Move Your WordPress Feeds to a Sub-domain - Page 3

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>

1 2 3

Or get RSS feed

Author:

Syam Kumar is the Owner and Editor of WebMaster View. He is based in Cochin, Kerala, India. His interests include information design concepts, standards compliant web development and Linux.

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.

Comments : 4

  1. Very useful function. I was searching it for long time. Thanks

    cherthala friends

  2. Thank you so much for sharing this. This is a really great source which can improve websites. Thanks again!

    Video Avatar

  3. I was searching for this and got it here.. great share

    amandkumar

  4. 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!

    Vuxenleksaker

Pings/Trackbacks: 8

  1. What You Need to Know About Domain Name Investing - WebMaster View
  2. links for 2010-10-04 « dupola's Collections
  3. wp-popular.com » Blog Archive » How to Move Your WordPress Feeds to a Sub-domain – Page 2 – WebMaster View
  4. How to Move Your WordPress Feeds to a Sub-domain – WebMaster View
  5. ajf7688 Blog - How to Move Your WordPress Feeds to a Sub-domain – WebMaster View
  6. How to Move Your WordPress Feeds to a Sub-domain - Domain Blog
  7. Tweets that mention How to Move Your WordPress Feeds to a Sub-domain - WebMaster View -- Topsy.com
  8. Setup a separate sub-domain for media files in WordPress - WebMaster View