Output WordPress Gallery In Sidebar

A client really wanted to make use of the built in WordPress gallery shortcode. It’s a really cool built in feature to WordPress that easily allows them to manage basic photo galleries. But we wanted the gallery thumbnails to be generated in a sidebar, not the actual Page or Post.

This took a bit of time to figure out how to do, but luckily it was right in front of me in the WordPress documentation.  I just entered the following in the sidebar.php file (just gallery in the brackets):

echo do_shortcode('[the-word-gallery-goes-here]'); 

You can add that standard gallery shortcode options to that as well. So simple, I can’t believe it took me as long as it did to figure this one out.

Leave a Reply

Your email address will not be published. Required fields are marked *