Blog
WordPress Gallery Shortcode
- August 18th, 2010
- WordPress
- 0 Comments
Apparently this little gem has been around since WordPress 2.5 (and as of this writing we’re at 3.0.1) but I’m just now finding out about it. Good grief!
Gallery Shortcode Tutorial
So you want a fancy WordPress gallery without having to install a gallery plugin? Yes, you can do that. Easy.
It’s as simple as the following steps:
- Start a new post (or edit an existing post)
- Using the “Add an image” icon next to “Upload/Insert” above the WYSIWYG editor, add the images you want to display as a gallery on your post. This is technically attaching images to the post.
- Wherever you want your thumbnail gallery of images to appear, add the shortcode-
[gallery]
And that’s pretty much it! Easy right? I told you so!
Gallery Shortcode Options
The [gallery] shortcode also has other options available naturally if you want to customize your WordPress gallery.
The basic options are pretty straight forward and include- columns, id, size.
[gallery columns="2"]
The columns options, as you might imagine, sets the number of columns the gallery will have. The default is 3 if you don’t specify a value. If you set columns to 0, row breaks will not be included in the output.
[gallery id="911"]
The id option allows you to pull images from a different post. So if your image gallery you want to display is attached to another post, rather than reupload all those images, just specify the post id of the original post and you’re in business.
[gallery size="large"]
The size option allows you to choose what image size you want to use in your gallery. The default is “thumbnail” but you can also choose- medium, large and full. (Those sizes of course are the image sizes in your gallery that your image is resized to when you upload, except full of course, which is the original image size.)
Gallery Shortcode Advanced Options
There are some other advanced options as well that let you control thumbnail order, including or excluding particular images from the gallery and XHTML output. If you’re interested in those, I recommend you check out the WordPress Codex.
Gallery Shortcode Example
I uploaded a few photos to this post myself to show how this works. So without further ado, here’s an example of the gallery shortcode.
For the above gallery, I just used [gallery columns="2"]
.
Hope you found this as interesting and useful as me! And all these photos are copyrighted. :)
Leave a Comment