Shortcodes and Custom Fields

Posted by user1429400 on Stack Overflow See other posts from Stack Overflow or by user1429400
Published on 2012-06-24T20:56:32Z Indexed on 2012/06/24 21:16 UTC
Read the original article Hit count: 145

How do I get shortcodes to process properly in custom fields?

I've tried using the code below, but I cannot figure out where to place it ("button" is the name of the field):

<?php 
if ( get_post_meta($post->ID, 'button', true) ) 
echo do_shortcode(get_post_meta($post->ID, 'button', $single = true));
?>

As of now, the shortcode is working in the sense that the button is displaying, but the shortcode text is displaying where the "buy now" button is supposed to be. See screenshot:

http://i.imgur.com/41vsr.png

© Stack Overflow or respective owner

Related posts about Wordpress

Related posts about custom-fields