• Resolved doulie

    (@doulie)


    I want to set this player up in my single post template file to get the mp3 fileurl from a custom field.

    I am using the exact code from this post, marked as ‘resolved’ https://ww.wp.xz.cn/support/topic/dynamic-url-in-shortcode?replies=2

    This is the code i am using

    <?php
    $post_meta_value = get_post_meta($post->ID, 'sound_url',TRUE);
    echo do_shortcode('[sc_embed_player fileurl='.$post_meta_value.']');
    ?>

    I’ve even given my custom field the name ‘sound_url’ to try and preserve the code above exactly as it is. However it does not work!! If i add the fileurl link directly it works, but adding any sort of variable does not.

    For a while, the player would show up, but when i press the play button it would play no sound. However ever since i changed the post custom field to ‘sound_url’ i get the following error Compact Audio Player Error! You must enter the mp3 file URL via the "fileurl" parameter in this shortcode. Please check the documentation and correct the mistake.

    I have been stuck on this issue for a couple days, i’ve done as much research as i can and cannot find a solution. If anyone can help (not just plugin developer) it will be greatly appreciated.

    https://ww.wp.xz.cn/plugins/compact-wp-audio-player/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor mbrsolution

    (@mbrsolution)

    Hi if you add the following code to your theme template it should work.

    <?php echo do_shortcode('[sc_embed_player fileurl="URL OF THE MP3 FILE"]'); ?>

    Thread Starter doulie

    (@doulie)

    @mbrsolution
    It seems like you did not ready my post at all. I want the fileurl to be dynamic. How do i do that?

    Thread Starter doulie

    (@doulie)

    I found the problem.

    I am using the plugin Advanced Custom Field to create my custom field. For some reason it does not return the file url when its called with a variable. You have to use the short code ‘get_field’

    So my code now looks like this
    echo do_shortcode('[sc_embed_player fileurl='.get_field('song_url').']');

    and it works!

    Hope this helps someone out there.

    Plugin Contributor mbrsolution

    (@mbrsolution)

    Hi, sorry for not reading your question properly. I am also happy you found a solution and thank you for sharing. I am sure someone will find your solution helpful.

    Kind regards

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Dynamic Link in template files’ is closed to new replies.