Skip to content

Instantly share code, notes, and snippets.

@n1c
Created July 13, 2012 09:28
Show Gist options
  • Save n1c/3103881 to your computer and use it in GitHub Desktop.
Save n1c/3103881 to your computer and use it in GitHub Desktop.
mxbuilder wordpress custom page template
<?php
/*
Template Name: mxbuilder custom rss feed
*/
$numposts = 10;
function mxbuilder_format_date($timestamp = null) {
$timestamp = ($timestamp == null) ? time() : $timestamp;
return date(DATE_RSS, $timestamp);
} // mxbuilder_format_date
$cat = (isset($_REQUEST['custom_cat'])) ? $_REQUEST['custom_cat'] : "";
$posts = query_posts('showposts=' . $numposts . '&cat=' . $cat);
$lastpost = $numposts - 1;
header("Content-Type: application/rss+xml; charset=UTF-8");
echo '<?xml version="1.0"?>';
?><rss version="2.0">
<channel>
<title></title>
<link></link>
<description>Latest posts</description>
<language>en-us</language>
<pubDate><?php mxbuilder_format_date(strtotime($ps[$lastpost]->post_date_gmt)); ?></pubDate>
<lastBuildDate><?php mxbuilder_format_date(strtotime($ps[$lastpost]->post_date_gmt)); ?></lastBuildDate>
<managingEditor></managingEditor>
<?php foreach ($posts as $post) { ?>
<item>
<title><?php echo get_the_title($post->ID); ?></title>
<link><?php echo get_permalink($post->ID); ?></link>
<description><?php echo '<![CDATA[' . apply_filters("the_content", $post->post_content) . ']]>'; ?></description>
<pubDate><?php echo mxbuilder_format_date(strtotime($post->post_date_gmt)); ?></pubDate>
<guid><?php echo get_permalink($post->ID); ?></guid>
</item>
<?php } ?>
</channel>
</rss>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment