Hidden Gallery Shortcode for WordPress
*** Updated ***
Well, ok … it’s not a hidden tag, but it is a feature many of us aren’t aware of in WordPress.
I have seen many people on Twitter asking for a good Gallery plug-in for WordPress. Our choice for a plug-in would be NextGen. But, it occurred to me that many people don’t realize that WordPress has this feature built in already. It’s not the prettiest or the coolest gallery I have seen. But it does the job in a pinch.
The setup for a gallery is very easy. And inserting it into a post or page is done with a “shortcode”.
First, start a new post and give it a title. Then, using the Media Toolbar, add in your images. The Media Toolbar is that row of icons just above the editing area start with “Upload/Insert”. Click on the first icon to open the Media Uploader.
I have trouble with the Flash Uploader so I use the Browser Uploader.
I upload my image, and select the options I want for that image. DO NOT click on “Insert into Post”. ONLY click on the “Save all changes” button. Your image will then be added to the Gallery and this will be reflected in the Media windows tabs.
Add as many pictures as you want, always clicking on “Save all changes”. You will see the number of images in your gallery increase. After uploading and clicking the correct button to save, you are always taken to the gallery tab. After you have uploaded you last image, select the option you want for your gallery. When you’re finished, click on “Insert Gallery”.
You should now see a Gallery shortcode appear in your post similar to the following:
gallery link="file" orderby="post_name"
You can also assign your own tags for enclosing the various elements of the image gallery. I have select tags to enclose my items, thumbnails and captions.
gallery link="file" orderby="post_name" itemtag="div" icontag="span" captiontag="p"
Here is my result (courtesy of Matt Stuart):
There is more about this shortcode in the WordPress Codex.
Update: We have found a Lightbox plugin for this WordPress Gallery code as well. You can get the plugin here. We have been very pleased with this plug-in as it gives your site that extra needed level of professionalism for photo galleries in WordPress. Have a look at our implementation of this WordPress Lightbox Gallery Plug-in.
11 Comments on “Hidden Gallery Shortcode for WordPress”
Adding a Contact Us Form to WordPress | Siam Communications Web Services & Tools16 July 2010 at 18:03
[…] added to simplify many of the common tasks a blogger needs to deal with. Previously, we dealt with How to Add a Photo Gallery for self hosted blogs. In today’s entry, we will show you how easy it is to add a simple […]
sho23 May 2010 at 11:38
I, like Jeff Tovar, would also want to know how to go about editing the gallery shortcode… in my case I’d like to add around all the images that are in a gallery
admin23 May 2010 at 11:48
You can simply use the tag
to include all pictures in a gallery for a given post/page.
You might want to visit the Author’s Gallery home page to read up on the latest version and documentation.
William9 April 2010 at 19:46
I am not an expert in WordPress so I was not aware of this fact . Thanks for making me aware that I can do this also in wordpress.
Chris21 March 2010 at 08:54
Thanks for this post! I just discovered that WordPress had this feature today, but I did not have any idea how to use it and I came across your page while looking for an example.
Jeff Tovar11 December 2009 at 12:03
Would you know how to edit the Gallery shortcode so that it links the image to nothing? I simply want to display the gallery, not have it linked to the file or attachment page. I’ve Googled for a while now and found nothing on how to change this. It seems simple enough!
Thanks in advance.
Eric3 November 2009 at 11:08
Unfortunately, there isn’t a straightforward way to do this specifically for each image. However, you can assign a Category to the post that would contain photos specific to that category. This isn’t really assigning the photos to a category but it does help a little.
Jen3 November 2009 at 01:10
Thanks for the great easy explanation. Is there anyway to upload pictures to categories? I would like to seperate my pictures into categories…
Jenny6 October 2009 at 04:39
I just stumbled across your post today when trying to figure out if I can control which images go in the gallery? Say I have 3 images that I want to be a gallery and then just one image floated in the text.
Do you know if I can remove the 4th image from the gallery, it seems it adds it in automatically? (i’m using wordpress 2.8.4)
Vincent28 September 2009 at 09:22
Thanks! I’m new to WordPress and had been trying to figure out how to do this. Other instructions I’d found weren’t as clear. I appreciate the explanation/instructions.
Matt Brewster27 August 2009 at 16:38
Thanks for this, never knew it existed!