I am trying to use the gallery shortcode multiple times within a post, two images per gallery, 15 shortcodes per page. It will only work as expected with modal popup for the first ten iterations, the remainder it adds a normal link to the image attachment page.

Is this a limitation of the gallery shortcode or the post loop? I have looked in the gallery_shortcode function but can find no mention of how many times it can be used per post so I suspect it might be limited somehow within the post.

Can anyone shed any light on how I might go about fixing this?

Edit: As per request, the shortcodes are as follows

[gallery ids="123, 456"]

[gallery ids="234, 567"]


[gallery ids="345, 678"]

You can use the shortcodes exactly 10 times in the post and get the expected response, with images displaying as expected, filling available width with caption style, modal popup, etc.

After you have used the shortcode 10 times, the images render differently on the page as simple static images with a fixed size.

  • Can you please edit your question and include a handful of the shortcodes?
    – Caleb
    Commented Jun 15, 2023 at 14:17
  • Are you using a plugin to provide the modal, or is it perhaps a feature of your theme? I don't think WP by default uses a modal for gallery images.
    – Pat J
    Commented Jul 12, 2023 at 4:27
  • You can view the gallery shortcode in the Wordpress Codex, it's a built in feature. codex.wordpress.org/Gallery_Shortcode
    – commbot
    Commented Jul 14, 2023 at 4:52
  • I spun up a test site to check and yes, it looks like the modal is a theme item. Investigating further...
    – commbot
    Commented Jul 14, 2023 at 5:55


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.