WordPress NextGen Gallery Shortcode Fun

I had to put a gallery on a small site recently and I couldn't be bothered writing my own or messing with WordPress' built in gallery system, so I plucked for NextGEN Gallery plugin.

It's nice enough and seems to do the trick quite well, including built-in lightbox functionality. It's been around for donkey's years so there's no point me going over the same ground that others have covered countless times but there's some things I found that were not well documented or talked about.

Firstly, how can I put the gallery on the page without putting it into a post or page?

Well I couldn't find a simple do_action call to do this, there may be one but I didn't find it. Instead, I used the handy shortcodes it provides and simply ran do_shortcode() with the shortcode I wanted as the parameter.

[ngg_images gallery_ids="1" display_type="photocrati-nextgen_basic_thumbnails"]

There's reasonable documentation on shortcode over on the NextGEN site: http://www.nextgen-gallery.com/nextgen-gallery-shortcodes/

As it always seems, the case for me, I needed to use some of the lesser known parameters which few if any sites mention. This is the crux of why I write this post - it's more of an aide-memoire for myself really.

Some interesting options are:

  • show_slideshow_link - set to 0 to remove the link to the gallery page
  • override_thumbnail_settings - if you want to use thumbnail_height and thumbnail_width you'll need to set this to 1
  • order_by - use any of the field names from the ngg_images table
  • order_direction - Simple, just ASC, DESC or even RAND()

I ended up with quite a monster of a shortcode but it does the job nicely:

[ngg_images gallery_ids="1" display_type="photocrati-nextgen_basic_thumbnails" gallery_width="200" gallery_height="200" show_slideshow_link="0" override_thumbnail_settings="1" thumbnail_height="90" thumbnail_width="90" number_of_columns="3" images_per_page="9" order_by="pid" order_direction="DESC"]

It's certainly worth a look and boasts about 8 million downloads so far which is huge. Well worth a look and there's a paid-for pro version if you are able to show their coffers some love. http://www.nextgen-gallery.com