How to add a gallery in WordPress with a lightbox effect is one of the hottest question that we have been getting lately through our contact form, so we have decided to cover it. Many beginners are not aware that WordPress has a built-in gallery feature that can be used on any post or page. In this article, we will show you how can add the native gallery in a WordPress post or page. We will also show you how to install a plugin that will allow your users to open the full-size images in a lightbox which will keep them from going to a different page.
Adding a WordPress Gallery
First open an existing post/page, or create a new post. Next thing you need to do is upload a bunch of images to this post. Click the Upload Media icon to upload your new Gallery images.
Once you have uploaded all the images, make sure you come to the Gallery Tab. Scroll down until you see the Gallery Settings. Choose your ordering scheme, and decide how many columns you want your gallery to have. on this page. A good rule of thumb is to use 3 on 3 column layouts, 4 on 2 column layouts, and 6 on full width layouts, but it can vary depending on the theme you have. Once you have selected the settings, Click Insert gallery.
Now, you will see a new icon that is added to the body of your post which represents the gallery.
Just click Update or Publish on your post/page, and the gallery will be added to the live site.
Adding Lightbox to the Native WordPress Gallery
If you try to click any of the thumbnails in your new gallery, you’ll notice they just open up a separate attachment page in a new window which is not very user-friendly. But, you also want to give the users to view the full-size images which is why we will install a simple plugin called jQuery Lightbox For Native Galleries.
First, Install and Activate the Plugin.
Next, you need to go to Settings » jQuery Lightbox. Select the theme you want to use for your lightbox window.
Now come to your post, and test your gallery. It should be working fine.
Congratulations, you have now added a gallery with a lightbox to your WordPress post or page. Final preview would look something like this:
FAQ from the Comments
– Binoy in the comments asked that if there was a way to select which image shows up in the gallery because by default all images attached to the post are added. Leo was kind enough to share the plugin Multiple Galleries which adds checkboxes next to images you have uploaded to a gallery in a post. Selecting checkboxes will include those images in that particular gallery.
E says
I’m so glad I found this article and this website. Love you guys right now!
Lynsey says
I love you! Is there any way to make the thumbnails smaller?
Editorial Staff says
Yes. Go to Settings > Media. Edit the thumbnail size. Then download a plugin called Regenerate thumbnails. Run that plugin, and thats it.
http://wordpress.org/extend/plugins/regenerate-thumbnails/
Admin
Sandeep Singh says
I am really Thankful for the suggestion to add Lightbox effect to the gallery. I really appretiate such kind of support and hope same for the future.
Mike says
Hello,
This is great, one question though is there a plugin or anything that is out there to make the gallery into a slideshow. For example say the first attached images shows up large and below are the thumbs of all the image in the gallery and you can click on a image to change the large image rather than a lightbox effect.
Thanks,
Mike
Editorial Staff says
Not sure if a plugin like that exists.
Admin
Renee says
Pretty sure that Fancybox plugin does that. You can enable or disable lightbox and thumbnails.
Emma Beatty Howells says
Thanks for a great solution I am new to all this and am trying to work out the easiest way to manage photogalleries on line – this keeps it simple and elegant! Something else I found useful was an App that watermarks photos with the minimum of fuss… ‘ImageBucket’.
Tiaan says
Thanks, works like a bomb!
Michael says
Seems easy enough. Is there a way to have captions under each picture? Also, when it opens to a lightbox, is there a way to have descriptive text in the lightbox with the image?
Editorial Staff says
This plugin should be able to do what you are looking for: http://wordpress.org/extend/plugins/gallery-and-caption/
Admin
Alex says
I have a banner at the top of my website which displays a picture. When it opens the lightbox, the banner still appears over it. Is there any way, a code or something, which will stop this?
Thanks
Alex
Editorial Staff says
Probably happening because your banner has a very high z-index value set. Lower that value in your CSS. There are a lot of CSS tutorials covering z-index on the web.
Admin
JulieBozza says
This is a really cool solution, thank you! So much quicker and neater than what I was doing…
Is there a way, however, to choose which of the images appears as the main thumbnail? That is, the thumbnail that appears in the ‘feed’ before you open up the individual post.
Thank you in anticipation!
wpbeginner says
@JulieBozza The thumbnail for the post is selected by using Featured Image feature. In your post editor, look at the right hand side, below publish button there should be a box in that line called Featured image.
JulieBozza says
@wpbeginner Hello! Thanks for the reply. Unfortunately when I do that, it changes the banner image, but has no effect on the thumbnail in the post. I’m using the Twenty Eleven WordPress theme, so perhaps it’s giving the banner the priority, as it were.
wpbeginner says
@JulieBozza You are referring to these gallery thumbnail images right???
JulieBozza says
@wpbeginner LOL! Yes. I created the gallery post exactly as described above.
I don’t know if it would help to visit the post itself, but here’s the URL. Keep in mind that the site is a work in progress!
http://rupertfyoung.com/2011/09/pierrefonds-september-2011/
wpbeginner says
@JulieBozza The gallery works like it should.
http://rupertfyoung.com/category/gallery/ << If you are referring to the thumbnail image here, then that is controlled by your Featured Image or the first attachment I believe. Upload a featured image that is low in width (thumbnail size or something)… And it will not take over the header image.
wpbeginner says
@ukdazza The problem is with your site rather than this plugin. jQuery issues like these are very common. There is another jQuery that is causing this plugin to not work. You would have to change positions of the other jQuery code.
This is a game of trial and error when you encounter problems like these.
ukdazza says
I’m having a problem where we’re using slickr flickr plugin to create thumbnail galleries with lightbox features. However the lightbox isn’t working at all. According to the notes I can find online about this kind of problem with this plugin, it is likely there is more than one lightbox or more than one jQuery running – causing it to not run properly.
Lightbox doesn’t work. If you click a thumbnail it opens the image in the browser, which is rubbish.
Any ideas? I hoped you or someone might have an idea because I tried to install this plugin and it said the destination was already taken.
TGA says
Wow. Thank you SO much. I was using NextGEN gallery, but wasn’t allowed to let my client have galleries with thumbnails of various sizes. (Dumb). So I realized using the native gallery that would be possible, but then Highslide wouldn’t create a thumbnail viewer like it would with NextGEN. Point being, this was a lifesaver! It may not be perfect, but it’s A solution and now I can move on with the project!
wpbeginner says
@TejSanusi✔ This plugin has a way for users to view the next image as part of the same lightbox.
TejSanusi✔ says
Is there anyway to create a lightbox gallery that is enabled from one thumbnail. When the user clicks on the thumbnail, the lightbox is created, with a series of gallery images?
cata says
Is quite interesting the plugin mentioned in the article. I have also tested with good results this one http://wordpress.org/extend/plugins/lightbox-gallery/
Chris says
Thanks for the great writeup. I found this extremely useful. I do have a question though. What if I had a pretty large gallery of about 40 or 50 pics and I only wanted one of them displayed in the post and then when someone clicks on it they’d be able to scroll through the entire gallery? Is this possible? I’d rather not have all 40 pics displayed in my post and I think this would be useful.
Thanks!
Keith Davis says
Nice one boys.
Never knew that WordPress had a gallery function… do you guys know everything?
Might actually use this one day.
jonathan perrodin says
Hey thanks for this, I’ve been wanting to get this on my site, but was too lazy to look for a plugin that did it simply. This was perfect.
Mike Roberts says
I am an artist and illustrator and I continue to be disappointed by the options for displaying a gallery of images in WordPress. I live in hope that, sometime soon, some bright coder will answer my plea!
Gretchen says
I didn’t realize how hard it was to find a lightbox plugin that used the native WordPress gallery function until I started looking for one! I ended up with http://wordpress.org/extend/plugins/lightbox-plus/ because of its ability to specify via shortcode in each post/page gallery whether it was to use the lightbox setting or not. I actually like to use the attachment pages sometimes, and needed a lightbox plugin that would allow me to choose when to use it. I’d be curious to hear if anyone else has found another lightbox plugin with that feature.
Bronson says
Thanks for the information.
It’s great to be able to apply the lightbox effect to native galleries trather than having to go and manually recreate them.
Sonu says
How this works ? and do we need a lightbox class to every image on gallery ?
Editorial Staff says
No you don’t need to lightbox class every image on the gallery. It automatically does that for all images in the gallery. The class should be added on any other image that you have aside from the gallery..
Admin
Binoy says
The problem here is all the images in post show up on gallery. Any options to select images?
Editorial Staff says
No that is not possible yet.
Admin
Leo says
Hi! To select the images to show in the gallery try this plugin: Multiple Galleries, you can find it here > http://goo.gl/kNFer
Bye!
Editorial Staff says
Thanks for sharing this plugin. Updating the article to add this
Preston says
Each image should have some kind of wordpress number associated with it. I exclude images in the gallery with this code, hopefully it works for you:
[gallery link="file" exclude="Photo#, Photo#, Photo#"]