Reply
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #6728

    ckworld
    Participant

    How can I use a shortcode in a WP custom field?

    #6731

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

    #6732

    ckworld
    Participant

    In which file do I place the do_shortcode

    #6733

    ckworld
    Participant

    I did put do_shortcode( “pricemonth” ); in the functions.php of my child theme. Does not work

    #6734

    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.