Yup, that works, with a couple small changes–I used “gallery_ids” instead of container_ids. And then you add any additional filters to the shortcode, just like you would in the body of the page (making sure to use single quotes instead of double).
So, in my case, my code ended up looking like this:
<?php echo $shortcode = "[ngg_images gallery_ids='1' display_type='photocrati-nextgen_basic_slideshow' gallery_width='400' gallery_height='156']";
echo do_shortcode($shortcode); ?>
Works great. But, when I added the if statements, now I’m getting both the shortcode and the gallery showing up in the header. It’s the correct gallery and the shortcode associated with the page.
So my code is:
<?php
if( is_page('About St. Johns') ) $shortcode = "[ngg_images gallery_ids='2' display_type='photocrati-nextgen_basic_slideshow' gallery_width='400' gallery_height='156']";
elseif( is_page('AGM') ) echo $shortcode = "[ngg_images gallery_ids='3' display_type='photocrati-nextgen_basic_slideshow' gallery_width='400' gallery_height='156']";
elseif( is_page('Artist Series') ) $shortcode = "[ngg_images gallery_ids='4' display_type='photocrati-nextgen_basic_slideshow' gallery_width='400' gallery_height='156']";
elseif( is_page('What We Believe') ) echo $shortcode = "[ngg_images gallery_ids='5' display_type='photocrati-nextgen_basic_slideshow' gallery_width='400' gallery_height='156']";
elseif( is_page('Bulletins') ) echo $shortcode = "[ngg_images gallery_ids='6' display_type='photocrati-nextgen_basic_slideshow' gallery_width='400' gallery_height='156']";
elseif( is_page('Calendar') ) echo $shortcode = "[ngg_images gallery_ids='7' display_type='photocrati-nextgen_basic_slideshow' gallery_width='400' gallery_height='156']";
elseif( is_page('Choirs') ) echo $shortcode = "[ngg_images gallery_ids='8' display_type='photocrati-nextgen_basic_slideshow' gallery_width='400' gallery_height='156']";
elseif( is_page('Church Council') ) $shortcode = "[ngg_images gallery_ids='9' display_type='photocrati-nextgen_basic_slideshow' gallery_width='400' gallery_height='156']";
elseif( is_page('Confirmation') ) echo $shortcode = "[ngg_images gallery_ids='10' display_type='photocrati-nextgen_basic_slideshow' gallery_width='400' gallery_height='156']";
echo do_shortcode($shortcode); ?>
(And so on, for another 30 pages)
The website: https://st-johns-ucc.org/
And you’ll see the photo galleries in the headers.
Thanks!