Skip to content

Instantly share code, notes, and snippets.

@nickhempsey
Created March 3, 2012 18:13
Show Gist options
  • Save nickhempsey/1967199 to your computer and use it in GitHub Desktop.
Save nickhempsey/1967199 to your computer and use it in GitHub Desktop.
Wellspring Media XML
<?php
/**
Template Name: RSS Feed
**/
$numposts = -1;
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.'&post_type=sermon');
$lastpost = $numposts - 1;
header("Content-Type: application/rss+xml; charset=UTF-8"); ?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
<title>Wellspring Church</title>
<description>Join us each week as Pastor Trey Kelly teaches about the transforming power of a relationship with Jesus Christ.</description>
<link>http://www.wellspringchurch.tv</link>
<category>Religion and Spirituality</category>
<copyright>Copyright 2008 - Wellspring Church</copyright>
<language>en-us</language>
<managingEditor>tj@wellspringchurch.tv (TJ Goff)</managingEditor>
<pubDate><?php yoast_rss_date( strtotime($ps[$lastpost]->post_date_gmt) ); ?></pubDate>
<lastBuildDate><?php yoast_rss_date( strtotime($ps[$lastpost]->post_date_gmt) ); ?></lastBuildDate>
<webMaster>nick@studio412design.com (Nick Hempsey)</webMaster>
<itunes:subtitle>Pastor Trey Kelly</itunes:subtitle>
<itunes:summary>
Join Pastor Trey Kelly as he teaches how to live your life to the fullest by having a personal relationship with Jesus Christ.
</itunes:summary>
<itunes:category text="Religion &amp; Spirituality">
<itunes:category text="Christianity"/>
</itunes:category>
<itunes:keywords>Christianity, Trey Kelly, Wellspring, Myrtle Beach</itunes:keywords>
<itunes:author>Trey Kelly</itunes:author>
<itunes:owner>
<itunes:email>tj@wellspringchurch.tv</itunes:email>
<itunes:name>Wellspring Church</itunes:name>
</itunes:owner>
<itunes:image href="http://www.wellspringchurch.tv/Podcasts/WellspringLogoSquare.jpg"/>
<itunes:explicit>no</itunes:explicit>
<image>
<url>http://www.wellspringchurch.tv/podcasts/wellspringlogosquare_144.jpg</url>
<title>Sermons | Wellspring Church</title>
<link>http://www.wellspringchurch.tv</link>
<description>Love God. Love Others. Love Life.</description>
<width>34</width>
<height>32</height>
</image>
<?php foreach($posts as $post) { ?>
<item>
<title><?php echo get_the_title($post->ID); ?></title>
<description><?php echo '<![CDATA['.$post->post_content.' Watch the Video: <a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a>'.']]>'; ?></description>
<link><?php echo get_field('mp3',$post->ID); ?></link>
<author>trey@wellspringchurch.tv (Trey Kelly)</author>
<enclosure url="<?php echo get_field('mp3',$post->ID); ?>" length="45" type="audio/mpeg" />
<guid isPermaLink="true"><?php echo get_permalink($post->ID); ?></guid>
<pubDate><?php yoast_rss_date( strtotime($post->post_date_gmt) ); ?></pubDate>
<itunes:subtitle><?php echo get_the_title($post->ID); ?></itunes:subtitle>
<itunes:summary><?php echo $post->post_content.' Watch the video at wellspringchurch.tv'; ?></itunes:summary>
<itunes:duration><?php echo get_field('mp3_length',$post->ID); ?></itunes:duration>
<itunes:keywords>Wellspring Church, Myrtle Beach, Trey Kelly, <?php echo get_the_title($post->ID);?></itunes:keywords>
<itunes:author><?php echo get_field('speaker',$post->ID); ?></itunes:author>
<itunes:explicit>no</itunes:explicit>
</item>
<?php } ?>
</channel>
</rss>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment