Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: Custom Feed
- */
- $numposts = 5;
- function yoast_rss_date( $timestamp = null ) {
- $timestamp = ($timestamp==null) ? time() : $timestamp;
- echo date(DATE_RSS, $timestamp);
- }
- /*
- function yoast_rss_text_limit($string, $length, $replacer = '...') {
- $string = strip_tags($string);
- if(strlen($string) > $length)
- return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;
- return $string;
- }
- */
- $posts = query_posts('showposts='.$numposts);
- $lastpost = $numposts - 1;
- header("Content-Type: application/rss+xml; charset=UTF-8");
- echo '<?xml version="1.0"?>';
- ?><rss version="2.0">
- <channel>
- <title>Flashfictionmagazine</title>
- <link>https://flashfictionmagazine.com/</link>
- <description>The latest blog posts from Flashfictionmagazine.com</description>
- <language>en-us</language>
- <pubDate><?php yoast_rss_date( strtotime($ps[$lastpost]->post_date_gmt) ); ?></pubDate>
- <lastBuildDate><?php yoast_rss_date( strtotime($ps[$lastpost]->post_date_gmt) ); ?></lastBuildDate>
- <managingEditor>[email protected]</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['.'<p><span>by </span><strong>'.get_post_meta($post->ID,'pen_name',true).'</strong></p>'.the_excerpt_rss().'<br/><a href="'.get_permalink($post->ID).'">Read the rest</a>'.']]>'; ?></description>
- <guid><?php echo get_permalink($post->ID); ?></guid>
- </item>
- <?php } ?>
- </channel>
- </rss>
Advertisement
Add Comment
Please, Sign In to add comment