The NextGen Gallery plugin has a useful feature allowing images to be filtered for display using tags. Unfortunately there’s no obvious way to add a template tag. I had to make a site recently for the Eden Project Florilegium Society and needed to show captions on the tagged images. Fortunately I found a solution on the WordPress forums. Thanks trDiablo! I’m reproducing it here so I can find it again next time.

In the plugin’s lib folder shortcodes.php must be modified to include the template tag.

function show_tags( $atts ) {

'gallery' => '',
'template' => '',
'album' => ''
), $atts ));

if ( !empty($album) )
$out = nggShowAlbumTags($album);
$out = nggShowGalleryTags($gallery, $template);

return $out;

Similar additions must be made to nggfunctions.php.

function nggShowGalleryTags($taglist, $template = '') {

// $_GET from wp_query
$pid = get_query_var('pid');
$pageid = get_query_var('pageid');

// get now the related images
$picturelist = nggTags::find_images_for_tags($taglist , 'ASC');

// look for ImageBrowser if we have a $_GET('pid')
if ( $pageid == get_the_ID() || !is_home() )
if (!empty( $pid )) {
foreach ($picturelist as $picture) {
$picarray[] = $picture->pid;
$out = nggCreateImageBrowser($picarray);
return $out;

// go on if not empty
if ( empty($picturelist) )

// show gallery
if ( is_array($picturelist) )
$out = nggCreateGallery($picturelist, false, $template);

$out = apply_filters
('ngg_show_gallery_tags_content', $out, $taglist);
return $out;

Of course these changes will be lost in the next NextGen update.

Postscript: These days I no longer use the NextGen gallery on I’ve switched to the legacy version: NextCellent.