Home Forums ACF PRO oembed url to mp3 – how does it work


oembed url to mp3 – how does it work

  • Hello
    I have a url to an mp3 file in the oembed field – on the front-end I get a shortcode like this: [audio src="" /] instead of some mp3 player – what am I missing?

    Thank you in advance for your input.

  • Hi @mmjaeger

    Could you please try this code:

    $theEmbed = get_field('oembed_field_name');
    if(preg_match('/\[audio src="(.*)" \/\]/', $theEmbed)){
        echo do_shortcode($theEmbed);
        echo $theEmbed;

    I hope this helps.

  • Thank you James

    I’m sure your solution is more advanced – I came up with `if ( strpos( get_field( ‘resource_media’ ), ‘.mp3’ ) )
    echo do_shortcode( get_field( ‘resource_media’ ) );`

    I did the trick as well.

  • Hi @mmjaeger

    I don’t think my answer is more advanced, it just has a different method 🙂

    What it do is checking if the returned custom field is in an audio shortcode format or not. Just to make sure that it isn’t the content that’s returned by oEmbed service.

    I hope this makes sense.

  • I recently had the same problem while using WordPress 4.9.2 and ACF 5.6.7 with Genesis 2.5.3 on a MAMP 3 localhost development site. I attempted to embed two mp3 URLs and all I got on the front end was what appeared to be a raw shortcode.

    [audio src="..."/]

    James’ solution worked, but it took me a while to find it. It’s the first glitch I’ve had with ACF Pro, which otherwise works perfectly and is exceedingly well documented.

    If this is a recurrent problem, though, perhaps an adjustment to the OEmbed field code is needed. Or, in the meantime, you might copy this code to the documentation page. It might save some other people some time.

  • Any of you see or have an idea on how to do that same thing but for a Youtube embed?

    [youtube id="123456" width="600" height="350" autoplay="no" api_params="" class=""][/youtube]

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘oembed url to mp3 – how does it work’ is closed to new replies.