Support » Fixing WordPress » RSS 2.0 Enclosures

  • Resolved thoth92


    How can I change the wp-rss2.php file so that it only creates enclosures from the second, third, fourth, etc. rich media files in a post instead of just the first?

Viewing 7 replies - 1 through 7 (of 7 total)
  • I wrote a plugin to do that at


    Actually, my question still isn’t answered. I have a podcast and want to create separate RSS feeds for each type of file (MP3, OGG, WMA, and AAC) without creating a separate post for each one. How do I do that?

    Oh, I see. That’s more complicated. My first suggestion would be to stick with one format. Do you really need all those options? I’m more of a video person, but doesn’t everyone just use MP3s?

    If you’re committed to doing it I have an idea that will probably work but I haven’t tested it.

    Use my plugin to create an enclosure for every format in the post.

    Create a copy of wp-rss2.php for each format (give them names like wp-rss2-mp3.php, etc) then change the line <? php rss_enclosure(); ?> to <? php kg-rss_enclosure_filetype(); ?>

    Insert this function after the first line of the file:

    function kg-rss_enclosure_filetype() {
    global $id, $post;
    if (!empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password)) return;

    $custom_fields = get_post_custom();
    if( is_array( $custom_fields ) ) {
    while( list( $key, $val ) = each( $custom_fields ) ) {
    if( $key == 'enclosure' ) {
    if (is_array($val)) {
    foreach($val as $enc) {
    $enclosure = split( "n", $enc );
    if ( trim ( $enclosure[ 2 ] ) == "audio/mp3" ) {
    print "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>n";

    Change “audio/mp3” to whatever the mime type is for the file you want to enclose. I _think_ that will create a feed that only encloses the type you want. Then you just link to each feed from your site.

    Thank You! I’ll try it out.

    I just posted the same issue — I want a separate feed for my mp3 files and another feed for my ogg files. Did this technique work for you?


    I can’t get this to work either, trying to use it for separate WMV and Quicktime feeds.

    Parsing error, it says.

    Wish I knew PHP so I could tell what’s going on.

    Videobloggers around the world would be very happy to have a working answer to this problem!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘RSS 2.0 Enclosures’ is closed to new replies.