Title: Dynamic URL in Shortcode
Last modified: August 21, 2016

---

# Dynamic URL in Shortcode

 *  Resolved [snomo](https://wordpress.org/support/users/snomo/)
 * (@snomo)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/dynamic-url-in-shortcode/)
 * Trying to use this plugin to be able to play a sound file unique to each post.
   I guess there are two ways to do it, one is to get the file from the custom file
   field, but I don’t think the plugin supports that. The second way is to have 
   a url for each post the shows the sound file location.
 * How would I go about populating the URL in the shortcode with a custom field 
   value related to a custom post?
 * I’ve tried the following but can’t get it to work…
 *     ```
       <?php $post_meta_value = get_post_meta($post->ID, 'sound_url',TRUE);
       echo do_shortcode('[sc_embed_player fileurl= ".$post_meta_value."]'); ?>
       ```
   
 * and neither does this…
 *     ```
       <?php echo do_shortcode('[sc_embed_player fileurl= "'.get_post_meta($post->ID, 'sound_url', true).'"]'); ?>
       ```
   
 * thanks!
 * [http://wordpress.org/extend/plugins/compact-wp-audio-player/](http://wordpress.org/extend/plugins/compact-wp-audio-player/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [mra13 / Team Tips and Tricks HQ](https://wordpress.org/support/users/mra13/)
 * (@mra13)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/dynamic-url-in-shortcode/#post-3796699)
 * you should be able to retrieve the URL from a custom field and use it with the
   plugin.
 * Your sample code looks wrong which is most likely why it is not working. Try 
   the following example:
 *     ```
       <?php
       $post_meta_value = get_post_meta($post->ID, 'sound_url',TRUE);
       echo do_shortcode('[sc_embed_player fileurl='.$post_meta_value.']');
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Dynamic URL in Shortcode’ is closed to new replies.

 * ![](https://ps.w.org/compact-wp-audio-player/assets/icon-128x128.png?rev=994411)
 * [Compact WP Audio Player](https://wordpress.org/plugins/compact-wp-audio-player/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/compact-wp-audio-player/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/compact-wp-audio-player/)
 * [Active Topics](https://wordpress.org/support/plugin/compact-wp-audio-player/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/compact-wp-audio-player/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/compact-wp-audio-player/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [mra13 / Team Tips and Tricks HQ](https://wordpress.org/support/users/mra13/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/dynamic-url-in-shortcode/#post-3796699)
 * Status: resolved