Executing Shortcodes in Custom Fields

While creating custom fields for a website this morning, I ran across a problem – short codes would not execute in the custom field. I came up with a solution that involves some complicated coding. I wasn’t really happy with this, as my client would have to remember a lot of code to use these custom fields on their website.

But, it turns out if you add the following code to your template file:

<php echo apply_filters('the_content', get_post_meta($post->ID,'CUSTOM_FIELD_NAME',true)); ?>

It will execute all short codes in the custom fields.

Comments are closed.