Performancing Metrics

Enclosures In WordPress RSS Feed

If you are into Podcasting then you’re familiar with RSS feeds featuring enclosures. This is a modification for wordpress that enables adding enclosures to your posts. These enclosures are then automatically added to the rss 2.0 feed.

Categories: WordPress Hacks



Comments

  1. James E. Robinson, III says: 1/10/2005

    Using the custom fields yields a very simple way to add the necessary info to a post. Then a little bit of code in wp-rss2.php:


    < ?php
    if ( isset($post_meta_cache[$post->ID]['enclosure'][0]) &&
    isset($post_meta_cache[$post->ID]['enclosure-file'][0]) ) {

    $encVal = trim($post_meta_cache[$post->ID]['enclosure'][0]);
    $encFile = trim($post_meta_cache[$post->ID]['enclosure-file'][0]);
    $encLength = filesize($encFile);

    $encType = "audio/mpeg";
    if ( isset($post_meta_cache[$post->ID]['enclosure-type'][0]) ) {
    $encType = trim($post_meta_cache[$post->ID]['enclosure-type'][0]);
    }

    echo "\t" . '' . "\n";
    }
    ?>

  2. James E. Robinson, III says: 1/10/2005

    well, that got munged, but you get the idea.