Forums

Get enclosure URL with get_post_meta (3 posts)

  1. nlaspf
    Member
    Posted 2 years ago #

    I'm trying to add a player into an podcast archive section. For that, I need to get the post enclosure url to feed it to the player.

    What i have now is this:

    <?php echo get_post_meta($id,'enclosure',true); ?>

    This returns the enclosure URL, but followed by the filesize and the file type, like this:

    http://www.someurl.com/enclosure.mp3 40419 audio/mpeg

    How can i do to get just the url?

  2. transitmonger
    Member
    Posted 2 years ago #

    I second this problem.

    More info:
    Noting that the key enclosure was passing extra info, I tried to pass "$single = false" (i.e., asked for an array instead of a string.)

    Unfortunately, it turns out that even with $single=false, it's still passing as though it were a single item. (i.e., it's not an array.)

    Maybe there's some sort of record separator for enclosures or something? It's probably a record separator that's standard for RSS, afterall, that's the reason for enclosures, I guess.

    Here's a better question. If I attach media to a post, how can I get that media?

    Thanks, T.

  3. transitmonger
    Member
    Posted 2 years ago #

    aha! Try this:

    array_shift(get_enclosed($post->ID))

Topic Closed

This topic has been closed to new replies.

About this Topic