I’ve spent some time searching for a solution but have not found 1 single example of how to do this.

I would like to place a shortcode in the value field of the Custom Field meta box in WordPress so it executes on the front end without hardcoding the shortcode into a template file.

enter image description here

Here’s my standard code i’m using to hook in the output of the shortcode on the front end via my template:

$two = get_post_meta( get_the_ID(), 'field_2_solid', true );
    if( ! empty( $two ) ) {
    echo '<div class="wrap">'. $two .'</div>';
}

I understand i can hard code it into the file but thats not flexible and not what i want to do.

Not sure it can be done.

1 Answer
1

Just use do_shortcode:

echo '<div class="wrap">'. do_shortcode( $two ) .'</div>';

Leave a Reply

Your email address will not be published. Required fields are marked *