• 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:

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

    How can i do to get just the url?

Viewing 2 replies - 1 through 2 (of 2 total)
  • transitmonger

    (@transitmonger)

    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.

    transitmonger

    (@transitmonger)

    aha! Try this:

    array_shift(get_enclosed($post->ID))

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get enclosure URL with get_post_meta’ is closed to new replies.