Title: Inserting a Shortcode into conditional with Custom Field
Last modified: August 20, 2016

---

# Inserting a Shortcode into conditional with Custom Field

 *  Resolved [cmdshiftdesign](https://wordpress.org/support/users/cmdshiftdesign/)
 * (@cmdshiftdesign)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/inserting-a-shortcode-into-conditional-with-custom-field/)
 * OK, so i have a custom field that is specifying the URL of an MP3 file for a 
   podcast, and the end goal is for that URL to be inserted into the shortcode for
   the audioplayer…
 * which looks like this [audio:[http://domain.com/audio.mp3%5D](http://domain.com/audio.mp3%5D)
 * SO I need something in the theme that says …
 * if there us something in the mp3_link field
    [audio: *stick it right here*]
 *     ```
       <?php $values = get_field('mp3_link');
       	   if($values)
          {
           echo '' . do_shortcode(' [audio:$values] ') . '';
          }
           ?>
       ```
   
 * I know i am missing something… this is the code i have and it returns [audio:
   [http://domain.com/audio.mp3%5D](http://domain.com/audio.mp3%5D) but …not as 
   code, but as text — so it’s not being translated to the audio player.
 * Eh?

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

 *  [tresinvolved](https://wordpress.org/support/users/tresinvolved/)
 * (@tresinvolved)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/inserting-a-shortcode-into-conditional-with-custom-field/#post-2866371)
 * How about if you do:
 * `echo '' . do_shortcode(' [audio:' . $values . '] ') . '';`
 * Where is the code coming from? A template file?
 *  [Andrew Norcross](https://wordpress.org/support/users/norcross/)
 * (@norcross)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/inserting-a-shortcode-into-conditional-with-custom-field/#post-2866372)
 * try wrapping it in wpautop
 *  [tresinvolved](https://wordpress.org/support/users/tresinvolved/)
 * (@tresinvolved)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/inserting-a-shortcode-into-conditional-with-custom-field/#post-2866373)
 * Actually, from looking at the Audio Player [FAQ](http://wpaudioplayer.com/frequently-asked-questions/),
   it looks like you want this instead:
 *     ```
       <?php $values = get_field('mp3_link');
       	   if($values)
          {
           echo '' . insert_audio_player(' [audio:$values] ') . '';
          }
           ?>
       ```
   
 *  Thread Starter [cmdshiftdesign](https://wordpress.org/support/users/cmdshiftdesign/)
 * (@cmdshiftdesign)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/inserting-a-shortcode-into-conditional-with-custom-field/#post-2866374)
 * Kyle (tresinvolved) fucking wins! Thank you! **YES!**
 *  [tresinvolved](https://wordpress.org/support/users/tresinvolved/)
 * (@tresinvolved)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/inserting-a-shortcode-into-conditional-with-custom-field/#post-2866381)
 * You may also want to do a
 * `if ( function_exists( 'insert_audio_player') )`
 * check somewhere there, just in case you remove the audio player plugin at some
   point.

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

The topic ‘Inserting a Shortcode into conditional with Custom Field’ is closed to
new replies.

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [tresinvolved](https://wordpress.org/support/users/tresinvolved/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/inserting-a-shortcode-into-conditional-with-custom-field/#post-2866381)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
