When I was researching the upcoming features for WordPress 2.9, I came across the following: “Add support for ‘include’ and ‘exclude’ to (Gallery Shortcode)”
I didn’t know what the gallery shortcode was all about so I looked into it and was pleasently surprised to discover a built-in WordPress feature that allows you to display a simple image gallery on a post or page.
The gallery shortcode will display all of the images that you have uploaded to that post or page as thumbnails. Here’s how you do that.
- Upload an image using the upload/insert button for the post or page where you want the images to display.
- Save the upload but don’t insert it into your post or page.
- Do this for each image that you want to display.
- Add
[gallery]
into your post or page where you want the gallery to be displayed.
The gallery will look like the following:
These are all photos of my favorite soccer goalie, Iker Casillas, who plays for Real Madrid. He has nothing to do with this post but I needed images for this article and he is one of my top ten celebrity crushes. ;-)
The gallery shortcode has a number of options that can be added to it. Some of them are:
- columns – You can specify the number of columns for the image display
[gallery columns="3"]
- id – This will display images attached to a specific post. For example, the gallery above displays the images for this post but by using the post id number I could display the images from a different post in this one.
[gallery id="292"]
- size – will set the size of the images. The default is thumbnail but you can also use the medium and large images.
[gallery size="medium"]
Obviously, this is not as full features as a gallery plugin like NextGen Gallery but for a quick and easy gallery on a post or page this shortcode works great.
I just can’t believe that I was completely clueless about it until recently.
If you want to read more about the gallery shortcode, there is information in the codex.
photo credit: voteprime
Yohan Perera says
Great tip Kim. Can’t wait till they release WordPress 2.9 stable version to try this out. One question though. How do you combine [gallery size="medium"] and [gallery columns="3"]
Kim Woodbridge says
Hi Yohan – Sorry if I was unclear. The shortcode works now – they are just adding some features to it in 2.9. You can use it now.
You can just combine the options gallery columns=”2″ size=”medium” enclosed in the brackets.
Dave says
Ohhhhhh… I didn’t know that either.
Of course I only found out last week that you can edit images inside the WordPress editor. I always switched to code view to add a class/resize/whatever.
.-= Dave´s last blog ..Add the WordPress search function to your Thesis header =-.
Kim Woodbridge says
Hi Dave – Oh good. I wasn’t the only one. It’s amazing how I keep learning new things.
I didn’t know there was an editor for a long time either – I guess I never needed to use it.
Betsy Wuebker says
Oh this is an awesome tip/discovery! We always have so many of Pete’s images and I’ve wanted to do this, but felt it had to be done singly and subject to WYSIWYG weirdness. Thank you, Kim; this is so very helpful.
.-= Betsy Wuebker´s last blog ..Down to Sleep: The November Garden =-.
Kim Woodbridge says
Hi Betsy – Great! I’m so glad it will help. I was surprised to discover it and it’s easy to use.
Jim says
Awesome!
Love the Iker gallery.
Kim Woodbridge says
Hi Jim – I should use examples that include Iker in all of my posts ;-)
Rick Castellini says
Fantastic tip..thanks Kim. Have I told you that you are “the real deal” before? If not, then there it is. Thanks!
.-= Rick Castellini´s last blog ..NEW Live Radio & Web Show today at NOON – Mountain Time! =-.
Kim Woodbridge says
Hi Rick – Thanks! This was a good find :-)
vered | blogger for hire says
Cool – thanks.
Yup, I remember your top ten celebrity crushes post. :)
.-= vered | blogger for hire´s last blog ..Genetic Testing for Children: Would You Do It? =-.
Kim Woodbridge says
Hi Vered – Thanks :-) I still like Iker ;-)
Dennis Edell says
I’d like to hear some usage stats, how much the system slows with the galleries and all..
.-= Dennis Edell´s last blog ..IS An Advertising Page Really A Good Idea? An Interesting Opposing View… =-.
Kim Woodbridge says
Hi Dennis – I’m not sure. But a lot of plugins use shortcodes so I can’t see how this would slow things down more than the plugins do.
Dennis Edell says
I’m just sayin, one of the first things drummed into your head as a newbie is, watch them pictures/images, it will slooooooooooow things down. lol
For that I always ask…
.-= Dennis Edell´s last blog ..IS An Advertising Page Really A Good Idea? An Interesting Opposing View… =-.
budi says
hi kim,
i’ve been looking for a tutorial on “how to put gallery in page of wordpress” in google and i end up in here
this is a good tutorial, but i somehow can’t display my gallery in wordpress page ( even though i can do it easily in wordpress post ),
i already put the gallery code :
[gallery size="medium"]
and still have blank
what did i miss ?
pls help me :(
Kim Woodbridge says
Hi Budi – Try switching to the html editor if you are using the visual editor and adding it that way. Also, do you have images uploaded that are associated with that page?