WordPress: Shortcode in Custom Field


Normally wordpress does not run shortcode that you put into a custom field. By default, Custom Fields display whatever value you enter, as plain-text, so if you try entering a shortcode, (in the format [shortcode] VALUE [/shortcode]) you’ll end up displaying the entire text, including the tags.

Add the following in your template file, it can be single.php or page.php or else

echo apply_filters('the_content', get_post_meta($post->ID,'your_custom_field',true)); 

or

$shortcode=get_post_meta($post->ID,'your_custom_field',true);
echo do_shortcode($shortcode); 
  • Jeff

    What about if you have shortcode interspersed with content.  Can you think of a way to do this?  With a filter perhaps?