WP-Mix

A fresh mix of code snippets and tutorials

WordPress Shortcode for Linked Image Gallery

This cool little snippet was contributed by VRS from Russia. It enables you to display a set of linked gallery images. You can use this technique anywhere in your theme template file or in any WordPress Post or Page.

Display linked gallery in Post or Page

Add this shortcode to any WP Post or Page:

[gallery link="file"]

The trick to getting the linked images is the link attribute.

Display linked gallery in theme template

Add this snippet to your theme template:

<?php echo do_shortcode('[gallery link="file"]'); ?>

Same basic idea, but here we are using do_shortcode() to output the shortcode via the theme template. Visit the WP Codex for more information about the gallery shortcode.

Thanks to VRS from Russia for the snippet.

Learn more

WordPress Themes In Depth