Title: Using Shortcode in Custom Fields
Last modified: August 20, 2016

---

# Using Shortcode in Custom Fields

 *  [mckaymultimedia](https://wordpress.org/support/users/mckaymultimedia/)
 * (@mckaymultimedia)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/using-shortcode-in-custom-fields-1/)
 * I have an audio/video player that uses shortcodes to display the player. In the
   theme I am using the code for audio/video players is suppose to be entered in
   a custom field. I need to be able to have shortcodes parsed in this specific 
   custom field in my theme. This is the isolated portion of the code in my single.
   php that calls on the custom field that I am dealing with:
 *     ```
       <div class="entry">
       <?php $video_code = thman_getcustomfield('video_code',get_the_ID()); if(!empty($video_code)) : ?><div class="video_code"><?php echo $video_code; ?></div><?php endif; ?>
       ```
   
 * I need this section to check if the video_code field contains shortcode and if
   so parse the shortcode so that it will be processed and appear in the post as
   it would if the shortcode was inserted in the editor. If not then just process
   as normal.
 * I have tried several different fixes from various forums to get this to work.
   I am in great need of some expert advice in modifying custom fields and shortcodes
   in themes.

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

 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/using-shortcode-in-custom-fields-1/#post-2348773)
 * You need to use the [do_shortcode()](http://codex.wordpress.org/Function_Reference/do_shortcode)
   call!
 * **UNTESTED:**
    `<?php echo do_shortcode('['.$video_code.']'); ?>`
 * HTH
 * David
 *  Thread Starter [mckaymultimedia](https://wordpress.org/support/users/mckaymultimedia/)
 * (@mckaymultimedia)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/using-shortcode-in-custom-fields-1/#post-2348813)
 * Thanks. I will give that a try.
 *  Thread Starter [mckaymultimedia](https://wordpress.org/support/users/mckaymultimedia/)
 * (@mckaymultimedia)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/using-shortcode-in-custom-fields-1/#post-2348815)
 * I tried inserting your code in various ways into the code above and it didn’t
   work. What it did was just echo the shortcode again so that it appeared twice
   in the post which is typically the result I have been getting with all the potential
   solutions I have found from scouring the web.
 * Thanks for the suggestion though. I know there is a solution to this puzzle somewhere.

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

The topic ‘Using Shortcode in Custom Fields’ is closed to new replies.

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * 3 replies
 * 2 participants
 * Last reply from: [mckaymultimedia](https://wordpress.org/support/users/mckaymultimedia/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/using-shortcode-in-custom-fields-1/#post-2348815)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
