Echo PHP inside of another PHP Echo? (2 posts)

  1. zwade
    Posted 2 years ago #

    Hey All,

    I'm not sure if I'm wording this right but here is what I have:

    <?php echo do_shortcode("[nggallery id='<?php echo get_post_meta($post->ID, 'gallery_id_box', true);?>']"); ?>

    I want to echo out the nextgen gallery shortcode, but have a echo inside the plugin for the plugin id number. I have a custom meta box setup so that all the user needs to do is enter the gallery id number in the box and it will be echo'd out and the gallery will show on the page. The code I have above doesn't work though and I need some help.

    I thought it may have to do with my quotes but I'm just getting into php so I wasn't sure. Any help is appreciated. Thanks

  2. Michael
    Forum Moderator
    Posted 2 years ago #

    use string concatenation; http://php.net/manual/en/language.operators.string.php


    <?php echo do_shortcode("[nggallery id='" . get_post_meta($post->ID, 'gallery_id_box', true) . "']"); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic