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?


Perhaps try:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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