Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • ckworld
    Participant

    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> );

    ckworld
    Participant

    In which file do I place the do_shortcode

    ckworld
    Participant

    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

    echo do_shortcode( $cf_value );

    Thanks,
    Aakash

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Subscribe for updates

Get updates on the WordPress plugins, tips and tricks to enhance your WordPress experience. No spam. View newsletter