• Resolved alenfrost

    (@alenfrost)


    Hi! I have a custom field to make an attachment of mp3 file. I display it in my php code like this:
    <?php
    if ( get_post_meta( get_the_ID(), ‘advanced_options_audio’, true) ) {
    echo ‘<audio controls=”controls”>
    <source src=”‘ . get_post_meta( get_the_ID(), ‘advanced_options_audio’, true ) . ‘” />
    </audio>’;
    }
    ?>

    In this case plugin is not working, ands the default player is displaing.
    How i can fix this?
    Thanks.

Viewing 1 replies (of 1 total)
  • Plugin Author pupunzi

    (@pupunzi)

    Hi,
    instead of adding the audio source you should add a link to the audio file:

    <?php
    if ( get_post_meta( get_the_ID(), ‘advanced_options_audio’, true) ) {
    echo ‘<a href="'. get_post_meta( get_the_ID(), ‘advanced_options_audio’, true ). '">my music</a>’;
    }
    ?>
    • This reply was modified 8 years ago by pupunzi.
Viewing 1 replies (of 1 total)
  • The topic ‘Displaing audio attachment from the custom field’ is closed to new replies.