Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

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.