Is there a way to only show the first 6 thumbnails on the actual post but when a user clicks on any of the thumbnails, then he can browse all images in the post gallery?

Essentially, I would like the exact functionality of this code but with only showing the first 6 thumbnails instead of all of them:

[gallery link="file"] 
  • Check out the Codex on the Gallery Shortcode. You can use attachment IDs to only grab 6 images. – Howdy_McGee Feb 12 '15 at 14:39
  • But how do I know the attachment IDs automatically for each gallery ? – JoaMika Feb 12 '15 at 15:53
  • Could this help anyone? codex.wordpress.org/Function_Reference/get_post_galleries – JoaMika Feb 12 '15 at 15:55
  • I don't quite understand the context. If you're using the Media Module ( pop up ) you can select 6 images and it will generate the shortcode for you. Are you trying to get a specific post / page gallery, then get the first 6 images of that gallery? – Howdy_McGee Feb 12 '15 at 15:55
  • I am looking for a custom shortcode that will automatically show the first 6 thumbnails on the actual post instead of all the thumbnails. – JoaMika Feb 12 '15 at 15:57

I know this is a bit of cheating but if I use this code essentially I achieve what I want, albeit the thumbnails are loaded on the page unnecessarily..

<div style="height:100px;overflow:hidden;">
[gallery columns="4" link="file"] 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.