• Hi! I am trying to create and make shortcodes work in Custom Fields. The code below works great.

    I am using More Fields plugin so instead of calling the value of the custom field using this code:

    <?php meta('features'); ?>

    I use this code instead:

    <?php if (get_post_meta($post->ID, 'features', true)) {
      $shortcode = get_post_meta($post->ID, 'features', true);
      echo do_shortcode("$shortcode");
      } else { echo ''; } ?>

    It works great except that it cannot properly output a shortcode within a shortcode.

    What I need to do is something like this:

    [paragraph][bold]This text is in bold.[/bold] This is the rest of my paragraph.[/paragraph]

    The code above properly outputs the [paragraph] shortcode but not the [bold] shortcode.

    Any suggestions? Thank you so much for the help.

Viewing 1 replies (of 1 total)
  • Thread Starter Hazel Z.

    (@cadencehart)

    In case someone has the same issue. Here is the code to use:

    <?php echo apply_filters('the_content', get_post_meta($post->ID, 'features', true)); ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Executing Shortcodes in Custom Fields’ is closed to new replies.