Skip to content

Instantly share code, notes, and snippets.

@chriscoyier
Created November 22, 2012 16:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chriscoyier/4132062 to your computer and use it in GitHub Desktop.
Save chriscoyier/4132062 to your computer and use it in GitHub Desktop.
<?php
/*
Template Name: RSS Gallery
*/
the_post();
$args = array(
'post_type' => 'screenshot',
'posts_per_page' => 10,
);
$query = new WP_Query($args);
header('Content-Type: '.feed_content_type('rss-http').'; 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:wfw="http://wellformedweb.org/CommentAPI/"
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/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
<?php do_action('rss2_ns'); ?>>
<channel>
<title>CSS-Tricks Gallery RSS Feed</title>
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
<link>http://css-tricks.com/gallery/</link>
<description>The RSS feed for the gallery at CSS-Tricks. Screenshots taken of interesting, effective, and aesthetic design on the web.</description>
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
<language>en-USd</language>
<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
<?php do_action('rss2_head'); ?>
<?php
while ( $query->have_posts() ) :
$query->the_post();
?>
<item>
<title><?php the_title_rss(); ?></title>
<link><?php the_permalink_rss(); ?></link>
<comments><?php comments_link(); ?></comments>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
<dc:creator><?php the_author(); ?></dc:creator>
<?php the_category_rss(); ?>
<guid isPermaLink="false"><?php the_guid(); ?></guid>
<description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
<content:encoded><![CDATA[
<figure>
<a href="<?php the_permalink(); ?>">
<img src="<?php echo get_post_meta($post->ID, 'screenshot', true); ?>" alt="<?php the_title(); ?>">
</a>
</figure>
<?php the_content(); ?>
<?php if (get_post_meta($post->ID, 'screenshot-link', true)) { ?>
<p><a href="<?php echo get_post_meta($post->ID, 'screenshot-link', true); ?>" class="button">Go To There &rarr;</a></p>
<?php } ?>
]]></content:encoded>
<wfw:commentRss><?php echo get_post_comments_feed_link(); ?></wfw:commentRss>
<slash:comments><?php echo get_comments_number(); ?></slash:comments>
<?php rss_enclosure(); ?>
<?php do_action('rss2_item'); ?>
</item>
<?php endwhile; ?>
</channel>
</rss>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment