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

I'm trying to make a product page template, editable by client, which will have 3 different NextGen Galleries per page.

In the product page admin area, I want the client to be able to select which 3 NextGen galleries to display, and in which order.

What do I put in my template page, and (I'm assuming) functions.php?

Here's a mockup of an individual product page how I want it to be, so you can see what I mean: https://dl.dropbox.com/u/10452828/LRG/a-project-page-mockup.jpg

I'm customising a theme, in which all the 'About the Product' fields etc are in the page template already, I just want to add selectable NextGen Galleries.

I've tried googling this but I'm not sure of exactly what terminology I should be searching for, so any advice would be appreciated. Thankyou!

share|improve this question
Just to clarify, I want it to be an actual part of the page template itself, with an input box for each gallery number (or similar controlled interface), not just shortcodes they would use in the content. – Aaron Jan 15 '13 at 21:49
up vote 0 down vote accepted

You can add galleries directly to a template by calling do_shortcode() to run the gallery shortcode.

<?php echo do_shortcode('[nggallery id="1" template="example"]'); ?>

Edit: sorry, writing decaffeinated so short attention span :)

Add some custom fields to your product pages to let your client pick which gallery goes on that product. If you like, just use the Advanced Custom Fields plugin and its friend the NextGEN Gallery Field add-on, which will let you add drop-down lists of gallery names to your edit pages.

Then in the template, get the value of each custom field and load the gallery using the shortcode as above, like this (replace 'gallery1' with your custom field names):

$gallery = get_post_meta(get_the_ID(), 'gallery1', true);
if ($gallery) {
    echo do_shortcode("[nggallery id='$gallery' template='example']");
share|improve this answer
Yes, thankyou. But how do I create the product page template so that it runs the client selected galleries for that particular product? – Aaron Jan 15 '13 at 21:57
@Aaron: please see updated answer – webaware Jan 15 '13 at 22:17
You, sir, are a hero. I shall try that and report back. Many thanks! – Aaron Jan 15 '13 at 22:54
NB: if you're going to use the Advanced Custom Field plugin and the NextGEN add-on, look at their code samples as their custom fields return more than just the gallery ID. – webaware Jan 15 '13 at 23:09
Thanks, I will do! – Aaron Jan 15 '13 at 23:32

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.