How can I use a shortcode in a WP custom field?
You can simply use [sc name="my_shortcode"] as custom field value.
While displaying the custom field, you have to call do_shortcode( <the_value_of_custom_field> );
do_shortcode( <the_value_of_custom_field> );
In which file do I place the do_shortcode
I did put do_shortcode( “pricemonth” ); in the functions.php of my child theme. Does not work
You have to use retrieve the custom field value like below
$cf_value = get_post_meta(get_the_ID(), 'pricemonth', TRUE);
and then use it on do_shortcode
do_shortcode
echo do_shortcode( $cf_value );
Thanks, Aakash
Get updates on the WordPress plugins, tips and tricks to enhance your WordPress experience. No spam. View newsletter