Advanced Gallery Management Using Shortcodes

The gallery “shortcode” is used in a Post or Page to display a thumbnail gallery of images attached to that post. When you insert a gallery using the basic tools presented in our Creating a Gallery of Images on Your Page or Post, you can find this code by switching to HTML view.

If you did not select any options your code would look like this:

 

However, in our  tutorial Creating a Gallery of Images on Your Page or Post, we had you order your images and select columns so if you go to HTML view on a post you inserted a gallery on using that tutorial and you did custom columns and ordered your images your short code looks more like this:

There are several options that may be specified using this syntax:

The following basic options are supported:

columns

?

specify the number of columns. The gallery will include a break tag at the end of each row, and calculate the column width as appropriate. The default value is 3. If columns is set to ‘0’, no row breaks will be included. For example, to display a 4 column gallery:

id
specify the post ID. The gallery will display images which are attached to that post. The default behavior, if no ID is specified, is to display images attached to the current post. For example, to display images attached to post 123:
size
specify the image size to use for the thumbnail display. Valid values include “thumbnail”, “medium”, “large” and “full”. The default is “thumbnail”. The size of the images for “thumbnail”, “medium” and “large” can be configured in WordPress admin panel under Settings > Media. For example, to display a gallery of medium sized images:

Some advanced options are available:

orderby
specify the item used to sort the display thumbnails. The default is “menu_order”. “RAND” (random) is also supported.

order

?

specify the sort order used to display thumbnails. ASC or DESC. For example, to short by ID, DESC:
 
include
comma separated attachment IDs,

will show only the images from these attachments.

exclude

comma separated attachment IDs,

excludes the images from these attachments. Please note that include and exclude cannot be used together.

One Response to “Advanced Gallery Management Using Shortcodes”