RSS Feed for Podcasts – WordPress Template

You can use your WordPress blog to publish podcasts on iTunes. Most podcasters use FeedBurner to add iTunes specific author information to podcast XML feed but if you prefer to skip FeedBurner, use these feed template.

Create a new page in your WordPress dashboard and give it a custom slug (say podcast). Now create a page-podcast.php file in your WordPress themes folder and copy-paste the following code. Remember to replace information in the highlighted lines.

The permalink of that WordPress Page will become the URL of your Podcast feed which you can now publish to the iTunes Podcasting directory. Here’s a sample Podcast XML feed generated using this RSS template.


/* RSS Feed for iTunes Podcast  */
/* Source: www.labnol.org       */

<?php    
  header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
  echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
?>

<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
    <channel>
        <title><? bloginfo_rss('name'); wp_title_rss(); ?></title>
        <link><? bloginfo_rss('url') ?></link>
        <language><? bloginfo_rss('language'); ?></language>
        <description><? bloginfo_rss('description') ?></description>
        <itunes:explicit>no</itunes:explicit>
        <itunes:owner>
            <itunes:email>amit@labnol.org</itunes:email>
            <itunes:name>Amit Agarwal</itunes:name>
        </itunes:owner>
        <itunes:author>Amit Agarwal</itunes:author> 
        <itunes:image href="http://placehold.it/1400x1400" />
        <itunes:keywords>tech, computers, tutorials</itunes:keywords>
        <itunes:subtitle>Get the most out of your tech.</itunes:subtitle>
        <itunes:summary>Podcast hosted by Amit Agarwal.</itunes:summary>
        <itunes:category text="Technology">
            <itunes:category text="Software How-To" /></itunes:category>
        <itunes:category text="Education"></itunes:category>
        <copyright>Creative Commons License</copyright>        
        <? $q = new WP_Query(array('posts_per_page'=>25,'tag'=>'podcast')); ?>
        <? while( $q->have_posts()) : $q->the_post(); ?>
            <item>
                <title><? the_title() ?></title>
                <link><? the_permalink() ?></link>
                <pubDate>
                    <?= mysql2date( 'D, d M Y H:i:s +0000',
                                get_post_time( 'Y-m-d H:i:s', true), false); ?>
                </pubDate>
                <guid isPermaLink="false">
                    <? the_guid(); ?>
                </guid>
                <description>
                    <![CDATA[<? the_excerpt(); ?>]]>
                </description>
                <itunes:explicit>no</itunes:explicit>
                <itunes:subtitle><? the_excerpt(); ?></itunes:subtitle>
                <itunes:summary><? the_excerpt(); ?></itunes:summary>
                <itunes:author>Amit Agarwal</itunes:author>
                <itunes:keywords>computers, tech, tutorials</itunes:keywords>
                <?php rss_enclosure(); ?>
            </item>
        <? endwhile; ?>
        <? wp_reset_postdata(); ?>
    </channel>
</rss>