I've spent some time searching for a solution but have not found 1 single example of how to do this.

I would like to place a shortcode in the value field of the Custom Field meta box in WordPress so it executes on the front end without hardcoding the shortcode into a template file.

enter image description here

Here's my standard code i'm using to hook in the output of the shortcode on the front end via my template:

$two = get_post_meta( get_the_ID(), 'field_2_solid', true );
    if( ! empty( $two ) ) {
    echo '<div class="wrap">'. $two .'</div>';

I understand i can hard code it into the file but thats not flexible and not what i want to do.

Not sure it can be done.

  • it looks like the suggestion by @TheDeadMedic will solve this - a cool magnifying glass effect you got there ;-)
    – birgire
    Aug 6, 2015 at 10:34
  • Yes @birgire Just worked out how to do that in preview > tools > Show magnifier. Aug 6, 2015 at 11:47

1 Answer 1


Just use do_shortcode:

echo '<div class="wrap">'. do_shortcode( $two ) .'</div>';
  • In the Custom Field Value field ( Meta Box )? Aug 6, 2015 at 9:28
  • 1
    No,the custom field value should remain the shortcode - it's only on the frontend you want to "execute" it, right? Aug 6, 2015 at 9:32
  • Yes @TheDeadMedic +1 Works perfectly. thanks. Aug 6, 2015 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.