WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a theme which has a "PRICE" custom field that only accepts numerical values. Is there anyway to parse shortcodes in that custom field so I can dynamically display the price using another plugin? Thanks!

share|improve this question

You can use the do_shortcode() function.

do_shortcode('[your-shortcode option1=foo option2=bar]');

Or in your case:

$price = get_post_meta($post->ID, '_price', true);

#Dynamically generate the plugin shortcode
$new_price = do_shortcode("[plugin-shortcode price=$price]");

Hope this helps you out!

share|improve this answer
Thanks for the response, but I'm a complete noob when it comes to WordPress functions. Do I just input the above code into my functions file, and then the shortcodes will begin to work when inputted into that custom field? Sorry for such a noob question, still learning WordPress -- and thank you for the help. – Hasan Khan Aug 17 '12 at 10:38
well it depends to where you want to output the shortcode. Than put the code above. – ifdion Aug 17 '12 at 12:05
-1 Downvote. The question relates to parsing the shortcode in the custom fields value field, not in the code. Also, don't do shortcode as its not efficient kovshenin.com/2013/dont-do_shortcode – Brad Dalton Aug 4 '15 at 8:30
Appreciate the feedback, but an edit would have been a better option here on a three year old question @BradDalton – Brian Fegter Aug 4 '15 at 15:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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