Using the gallery shortcode
In WordPress 2.5, the Gallery feature allows the option to add an image gallery to a Post or Page on your WordPress blog.
The [gallery] shortcode is used in a Post or Page to display a thumbnail gallery of images attached to that post. It can be used in its simplest form like this:
[gallery]
There are several options that may be specified using this syntax:
[gallery option1="value1" option2="value2"]
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:
[gallery columns="4"]
- id
- specify the post ID. The gallery will display images which are attached to that post. The default behaviour if no ID is specified is to display images attached to the current post. For example, to display images attached to post 123:
[gallery id="123"]
- size
- specify the image size to use for the thumbnail display. Valid values include "thumbnail", "medium" and "full". The default is "thumbnail". For example, to display a gallery of medium sized images:
[gallery size="medium"]
Some advanced options are available:
- orderby
- specify the sort order used to display thumbnails. The default is "menu_order ASC, ID ASC".
- itemtag
- the name of the XHTML tag used to enclose each item in the gallery. The default is "dl".
- icontag
- the name of the XHTML tag used to enclose each thumbnail icon in the gallery. The default is "dt".
- captiontag
- the name of the XHTML tag used to enclose each caption. The default is "dd". For example, to change the gallery markup to use div, span and p tags:
[gallery itemtag="div" icontag="span" captiontag="p"]