WordPress.org

Support

Support » Plugins and Hacks » Custom fields values in Shortcode outside the loop

Custom fields values in Shortcode outside the loop

  • Hi! im using the “review box” plugin, with a shortcode like this:

    [review pros="sample text" cons="sample text" verdict="sample text" score=77]

    that generate a formatted table.
    This shortcode must to be used in a post or a page, but i want to use it outside the loop, in single.php, cause i need to replace the “sample text” with values of custom fields.

    Now i’m tryng some code like this:

    <?php echo do_shortcode('[review pros="<?php echo get_post_meta($post->ID, "Pros", true); ?>" cons="<?php echo get_post_meta($post->ID, "Cons", true); ?>" verdict="<?php echo get_post_meta($post->ID, "Verdict", true); ?>" score=<?php echo get_post_meta($post->ID, "Score", true); ?>]'); ?>

    that generate the table but without results…
    how i can wrote this? it’s a sintax problem? Please,help me! 🙂

  • The topic ‘Custom fields values in Shortcode outside the loop’ is closed to new replies.
Skip to toolbar