0

Picture this scenario:

  1. From the "Add/Edit Post" page in WP, click the Add Media button.
  2. Click on "Create a Gallery" on the sidebar and do exactly that. Then insert it into your post. Let's call this gallery "Main Gallery".
  3. Save your post.
  4. Delete the gallery from the WYSIWYG editor.
  5. Save your post again.

Is there any way to edit "Main Gallery" once it's not visible from the editor?

I know it's not gone. I'm using the code in this post and the gallery is displaying. If I redo steps 1 to 3 again, creating another gallery (let's call it "Secondary Gallery"), the code referenced above does not display "Secondary Gallery", it displays "Main Gallery", so I know it still exists.

So is there a way to edit this now-hidden gallery? If not, any pointers as to how I could alter the code above to display only the newest created gallery instead of the oldest?

1

Wordpress galleries are not true "objects", they are just a kind of one time macro. There is no real DB of them, just a shortcode in the content and once you deleted it, there is no gallery any more (except for in the old revisions).

The code you referenced is a relic of the old days in which by default a gallery would have been all the images associated with a post, but those old days are long gone and unless you insert [gallery] manually, the current way is to add the ids of the images to the shortcode and once the shortcode is deleted.... puff you can't restore it from any other place except for backup.

1
  • I see, so better find a different way to display those galleries. it's been quite some time since I did this theme and it's slowly crumbling to pieces. hahaha Hopefully I can save it. Thank you! – enrique-ramirez May 10 '17 at 14:37

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.