WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] RSS 2.0 Enclosures (8 posts)

  1. thoth92
    Member
    Posted 8 years ago #

    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?

  2. Kyle Gilman
    Member
    Posted 8 years ago #

    I wrote a plugin to do that at http://www.15framespersecond.com/enclosureflex/

  3. thoth92
    Member
    Posted 8 years ago #

    thanx

  4. thoth92
    Member
    Posted 8 years ago #

    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?

  5. Kyle Gilman
    Member
    Posted 8 years ago #

    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.

  6. thoth92
    Member
    Posted 8 years ago #

    Thank You! I'll try it out.

  7. CNG
    Member
    Posted 8 years ago #

    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?

  8. bullemhead
    Member
    Posted 8 years ago #

    Hello,

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic