WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When a user creates a new post there is a meta field on the back end where they can enter the id of the nextgen gallery to display. I want to then display in their post the gallery which corresponds to the id they entered.

When I run the code below $meta echoes as #3 and the gallery shows, so I know that for this post rw_propGallery is set to 3, and that three is the id of an existing gallery.

$meta = get_post_meta(get_the_ID(), 'rw_propGallery', true);
echo $meta;
echo do_shortcode('[nggallery id=3]')

But if I switch it to

echo do_shortcode('[nggallery id=$meta]')

I get the number 3, and "Gallery not found". Any suggestions?

share|improve this question
up vote 2 down vote accepted

Perhaps try:

echo do_shortcode('[nggallery id=' . $meta . ']');
share|improve this answer
Thanks – Chuck Jun 30 '11 at 2:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.