NextGEN Gallery has a shortcode
nggtags that lets you dynamically build galleries and albums from images that have tags; Photocrati talk about it briefly on their working with albums page. One thing the shortcode doesn’t do, however, is let you specify a different gallery template for displaying the tagged images. Never being one to shrink from a challenge, my latest release of NextGEN Download Gallery offers a solution.
I built NextGEN Download Gallery as an add-on plugin for NextGEN Gallery to help me build websites for manufacturers. A common requirement on those websites is a section where trade and media can view and download high-resolution marketing images — product shots, labels, scenic and team shots, etc. Albums and galleries are usually all I need, but sometimes it would be nice to use tags and build virtual albums drawn from all of the galleries.
NextGEN Gallery doesn’t support many filter hooks, so it can be a little tricky to modify the behaviour of its shortcodes. I needed to create a new shortcode,
nggtags_ext, to make it accept a parameter for the gallery template. Usage is the same as the standard shortcode, except that you can also specify a template — like the download template. Here’s an example selecting images of sparkling wines into a virtual gallery:
nggtags_ext gallery="sparkling" template="download"]
Here’s how to create a virtual album, with a virtual gallery for each tag, using the download gallery template:
nggtags_ext album="red,white,sparkling,fortified" template="download"]
Of course, the shortcode isn’t limited to creating download galleries. If you have a preferred gallery template that you’d like to use with the tags shortcode, you can specify that instead, e.g. for a custom gallery template called awesomeness, install NextGEN Gallery and NextGEN Download Gallery plugins, and use this shortcode in a page or post:
nggtags_ext gallery="awesome" template="awesomeness"]
My hope is that once Photocrati have caught up with some of the important bugfixes for NextGEN Gallery, they’ll add the ability to use templates throughout NextGEN, and maybe also add some handy filter hooks. Until then, stop-gap measures like this one should help keep NextGEN Gallery the most useful gallery organiser on WordPress.