I have a function that looks at the attachment IDs from a normal gallery (let's ignore Gutenberg galleries for now, they have a different structure altogether):

\get_post_gallery( 0, False );, this should give me an array that has the key ids containing all attachment IDs.

Now, if we are to import the following .xml file, the theme unit test data, we see that 2 posts are created, namely "Post Format: Gallery" and "Post Format: Gallery (Tiled)", now, visually, they look the same in terms of what you think they'd do:

First gallery.

Second gallery

However, "Post Format: Gallery (Tiled)" is a Jetpack gallery (taken from the post's code):

[gallery type="rectangular" columns="4" ids="755,757,758,760,766,763" orderby="rand"]

and "Post Format: Gallery" is a normal gallery:


I rely on the ids key being there for my function to work. What option am I missing here? It seems there is a way to create a gallery without having IDs provided.

As a side note, whenever I create a non-Gutenberg gallery, it actually works, the output I'm given for get_post_gallery is:

array(4) { ["link"]=> string(4) "none" ["size"]=> string(6) "medium" ["ids"]=> string(8) "33,32,31" ["src"]=> array(3) { [0]=> string(68) "" [1]=> string(68) "" [2]=> string(68) "" } }

There are ids. Am I dealing with a malformed xml file here?


1 Answer 1


Prior to WordPress 3.5 there was no gallery editor, so the normal way of a gallery was inserted was just with the [gallery] shortcode, which would output all images attached to (i.e. originally uploaded to) the post. This functionality still works for backwards compatibility reasons. If this sounds awful, then yes, yes it was.

  • Oh, so I don't have to support it. Cool! Apr 12, 2020 at 6:11

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.