Multiple Galleries on a Page

In WordPress, by default a “gallery” contains all images attached to a post. It is possible to insert more than one gallery in a post by using the ‘include’ option within the gallery shortcode. Upload your images to the post as usual, and in the “gallery” tab of the media-manager, try and identify the image number of the attachment. In chrome, you can right click on the image and click “inspect”.

Then, insert the gallery using the gallery shortcode, using the include option (make sure to wrap in square brackets):

gallery include="460,459,458,457" link="file"

For example:

The gallery above includes images 460,459,458,457, the gallery below includes images 456,455,454,453.

29 Comments

  1. Well done! If you don’t mind, I’d like to link to this from my Not-the-official WordPress.com Gallery FAQ.

  2. Pingback: Not the Official WordPress.com Gallery FAQ « Random Acts of Photography

  3. Brilliant!

    Not entirely convenient … especially if there’s a lot of images that have been put into a custom order … but brilliant!

  4. Thanks a lot! Very helpful.

  5. Thank you, thank you. I wasted hours and hours trying to sort out my images. Your suggestion is the only one that works.

  6. Thank you, very much!!! Works like a charm :-)

  7. Can you tell me how to make just a single gallery on a post with Fancybox/lightbox looking display? With thumbnails like are on this page above? I can’t seem to do it.

    • It’s pretty easy.. I’m using the Lightbox2 plugin for the lightboxes, and then the thumbnails themselves are just styled with a little bit of CSS3 (rounded borders and drop shadows).

      • Its supposed to be pretty easy, yeah! Everyone says that and this developer of 15+ years can’t make it happen. I think I’m a tool ;)

        Tell me this – are you attaching thumbnails to the post to make the row of 4 thumbs I see above in this post? Are your thumbnail images generated from the real ones? Are the real images all the same size?

        I’ve been adding a few images to a post, not inserting them but inserting a gallery. My thumbnails appear in different sizes (some of them) no matter what theme I use. I never would have thought it so difficult to make a thumbnail gallery like you have on this page….I coulda hard coded it in half the time but alas….not the point; )

        • Ok, sounds like your settings might just be a little funny. If you go into your wordpress media settings (it’s at /wp-admin/options-media.php), you can select a thumbnail size, and also make sure to check “Crop thumbnails to exact dimensions”: that’ll ensure you get square thumbnails.

          Then insert a gallery with whatever images you want. I had to tweak the style sheets a little bit so that 4 would fit nicely across a page, and then I include “columns=4″ in the gallery shortcode so that I get 4 instead of the default 3 columns.

          Good luck!

  8. Muchas Gracias por tu manual, es genial!!! Saludos desde Venezuela.

  9. this gallery stuff spin my head in the past few day.
    Thanks to you man,…your stuff work, make my work a lot easier

  10. Thanks, this is really helpful.

    Question:

    Is there a way to put a slideshow with only certain pictures instead of a gallery? I’ve tried both of the gallery methods I know – the way you describe and by putting them into a different post – but neither seems to wok.

    Can you help?

    Thanks,
    Jo.

  11. This looks most helpful Bryce.

    I’m having difficulty identifying the image numbers. I’m using Chrome to inspect the element but I’m not seeing it. I must be overlooking something. Can you provide a bit of guidance?

    I’m looking to perform this task on this page: http://jaredbeasley.net/portfolio/photography/

    Many thanks!

  12. Hi

    Nice trick but when you click on any of these gallery they show all the pics from both galleries while it should show only those pics which are associated with the particular gallery

    Secondly, does any body know how to use lightbox just in one gallery while the images of other galleries will simply redirect users to different website/web pages

    Thanks

    • I find it useful that they display images from all galleries… as I’m generally doing related images on a page, that I’d just like to break up throughout an article. If you wanted to keep them separate, maybe try out nextgen gallery or something like that.. and create different galleries for each set of images?

  13. Thanks a lot! I’ve been searching for hours trying to solve this problem, thanks for your simple solution:)

  14. Superb man!!!!!!! million thanks..!

  15. I’ve been trying to figure this out for awhile now. I’ve tried your method, but for some reason, even when I use the image numbers (I’m assuming this is the number that appears after “id=” when using the “inspect element” link in Chrome), the gallery still displays ALL of the images that I have in the media library. This happens with multiple galleries on the page as well, where each gallery will show every image in the media library.

    I have been successful with inserting multiple galleries, but I can’t seem to figure how to get each gallery to only show the images I want.

    Any ideas? Thanks!!

    • Hmm. It should work..
      Do you have the latest version of wordpress installed?
      You might also try using “exclude” instead of “include” to exclude the images you *don’t* want in the gallery. Other than that, I’m not sure.

      • Thanks for the post! I’ve been looking out for a way to insert multiple galleries in one post.

        I encountered this problem as well, after some experimenting I discovered the solution is to remove the double quotation marks when using the include code. Could be a bug since the official support page lists its usage. Using the exclude code works as well, and for exclude you can do so with/without the double quotation marks.

        • THANK YOU PHAZER for pointing out that you don’t need double quotation marks with the ‘include’function!! You saved me hours trying to fix my galleries!!

  16. I love this work around, and it looks perfect with your example. For some reason, using your include code, my thumbnails show up perfectly, but when I click on the thumbs they open individually in a new window instead of opening into a larger gallery image. Any ideas? I’m using version 2.3 of lightbox plus.

    • That probably has to do with the way you’ve set up your gallery / lightbox. Make sure that each image is set to link to the image file (you can modify this in the media library settings for the post / page — on a per-image basis). Then in your lightbox settings, you’ll want to make sure it’s auto-lightboxing linked images. I haven’t used Lightbox Plus.. but if it doesn’t work, I’m using Lightbox 2 on this site, so you could always give that a try. Good luck!

  17. Okay so you will have to forgive me, I am new at this. So I want two galleries on the same main post. I want to be able to click through these galleries(1&2) separately while on the main post and I want them to only scroll through the images in each individual gallery. I tried inserting gallery1 on the main post and using code to link to another post in which i had created gallery2. I tried inserting both gallery 1&2 from two separate posts onto the main post. Both individual galleries contain the photos that they are supposed to, but no matter where I insert the galleries from, when I click through one gallery on the main post, the other gallery shows that picture in the enlarged thumbnail above it (but not in the thumbnail images below the gallery). In addition gallery1 no longer possesses the ability to move to the next image when the enlarged thumbnail is clicked on.

    • Not possible, with this setup anyway. The lightbox plugin will scroll through all of the gallery images on the page.
      You might consider using NextGen or something like that, and creating as many individual galleries as you need– though it may still be up to the lightbox plugin whether or not it pages through all the images, or just the images from each gallery. I don’t fully understand how that works.
      Good luck!

Leave a Comment