I moved my client's blog with nearly 800 posts from an ancient installation of WordPress to another host and a new version of WordPress. Now, several months later, we noticed that she had a few posts with gallery tags, and those tags are no longer working. I need to fix that, but I can't find any way to determine what images were used in the respective galleries. the posts just have something like this:

[gallery link="file" columns="4" orderby="ID"]

I do have a full export of the database (and all files) from the old site and looked through it, but can't find any info. However, it is quite possible I just don't know where to look.

The images do not show as attached to the specific posts in the media ui. For instance, one of her galleries was in a post where she picked a bunch of images from other posts.

Can anyone tell me how to find out what images were used in the galleries?

1 Answer 1


Gallery can include either:

  • specific images, in which case their IDs are explicitly listed in shortcode
  • all images attached to the post, in which case shortcode doesn't specify that (as in your example)

So your description is a little contradictory - if images weren't attached to the post, then that example wouldn't have worked in first place.

Otherwise something in migration or update process might have disrupted IDs or parent/child properties, look into that.

  • Thanks Rarst. I thought it was odd that the IDs weren't in the shortcode or attached, but figured I just didn't understand something. Your help confirmed it. It was obvious that the shortcodes weren't originally in the gallery shortcode, so I worked a bit harder on the second option. In case anyone with same problem happens along the post, here's how I solved it...
    – user47755
    Feb 18, 2014 at 5:02
  • I searched the wp_posts table of the original blog's database for entries with a post_type of 'attachment' and a post_parent of the id of the post the gallery was to display in. This listed all the attached images for the post and I was able to get the image names and create a new gallery with those images. Some images were not in WordPress, I'm not sure why. But I was able to find them in the uploads folder of my backup.
    – user47755
    Feb 18, 2014 at 5:07

Your Answer

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

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