Forums

Displaying link from enclosure custom field (2 posts)

  1. angus20184
    Member
    Posted 2 years ago #

    I put the following code in Function.php and use the user_rss_enclosure() to show the link of the enclosure without the duration and type.

    However, I am wondering if there is anyway I can trim the link without the domain?
    e.g.
    http://www.abc.com/mp3/123.mp3
    to
    /mp3/123.mp3

    function user_rss_enclosure() {
    if ( post_password_required() )
    return;

    foreach ( (array) get_post_custom() as $key => $val) {
    if ($key == 'enclosure') {
    foreach ( (array) $val as $enc ) {
    $enclosure = explode("\n", $enc);

    //only get the the first element eg, audio/mpeg from 'audio/mpeg mpga mp2 mp3'
    $t = preg_split('/[ \t]/', trim($enclosure[2]) );
    $type = $t[0];

    echo apply_filters('user_rss_enclosure', '' . trim(htmlspecialchars($enclosure[0])) . ' ' . "\n");
    }
    }
    }
    }

  2. angus20184
    Member
    Posted 2 years ago #

    I wrote the following, however, nth appear

    function openradio_rss_enclosure() {
    if ( post_password_required() )
    return;

    foreach ( (array) get_post_custom() as $key => $val) {
    if ($key == 'enclosure') {
    foreach ( (array) $val as $enc ) {
    $enclosure = explode("\n", $enc);
    $openradiomp3 = explode(" . ", $enclosure[0]);
    echo $openradiomp3[2];
    }
    }
    }
    }

Topic Closed

This topic has been closed to new replies.

About this Topic