• I created a custom field for my posts called soundclip1. It’s a url for an uploaded mp3 file.

    I want to call that custom field (called soundclip1) within a sound player shortcode in my template.

    This is the shortcode:

    [sc_embed_player fileurl="URL OF THE MP3 FILE"]

    This is the shortcode as php in the template

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

    Here is my attempt that is not working.

    <?php $soundclip1 = get_post_meta($post->ID, 'soundclip1', true); if( $soundclip1 ) echo do_shortcode('[sc_embed_player fileurl="' . $soundclip1 . '"]'); ?>

Viewing 1 replies (of 1 total)
  • Thread Starter jjrocket

    (@jjrocket)

    Actually, I think my php is correct.

    The problem is that the shortcode is pulling the Attachment ID instead of the URL for the custom field value.

    I’m using Advanced Custom Fields plugin and I have File URL specified for the field.

    I can’t figure out what the problem is.

Viewing 1 replies (of 1 total)
  • The topic ‘php help: want to echo a custom vield value within an echo shortcode in template’ is closed to new replies.