I was wondering if there is a filter that allows me to enable short codes to work inside the custom meta fields in my posts.

I know the following code enables it in widgets:

add_filter('widget_text', 'do_shortcode');

And where would I have to put a code? My theme has shortcodes.php also meta-boxes.php

Thanks in advance.

1 Answer 1


You could try running the content of the custom field through the do_shortcode() function when you output. e.g. given a custom field name of 'custom field'

echo do_shortcode( get_post_meta($post->ID, 'custom-field', true) );
  • Thanks @nothingtosee, but there would I have to add this code? Functions.php or somewhere else?
    – Mantas
    Oct 6, 2014 at 5:03
  • Anywhere you intend to output (i.e. in the theme templates) Oct 6, 2014 at 5:20
  • sorry I just want to make sure my code is right before I put it in: <?php echo do_shortcode( get_post_meta($post->ID, 'Price Check:', true) ); ?>
    – Mantas
    Oct 6, 2014 at 19:52
  • As long as your custom field key is 'Price Check:' then yep. Oct 7, 2014 at 8:36
  • thanks, but I still can't get it work
    – Mantas
    Oct 7, 2014 at 18:15

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.