WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm making image gallery plugin and I'm not sure what is the best way to store data in WordPress. Plugin can contain multiple gallery instances with some options and each gallery contains images with options. Gallery can be added to site using simple shortcode, something like this: [mygallery id="gallery1"].

So should I use add_option() and store all data in one field or just create two tables for galleries and gallery items?

Thanks for advice.

share|improve this question
up vote 2 down vote accepted

Depends on what you want to store.

Note: "Post Meta Storage Engine" is no official term. I just used it to surround/house the public API/functions set in a nice name.

share|improve this answer
Thanks, I want to store text data e.g. link to images, effect types, titles... – Marvin3 Sep 1 '11 at 13:18
@TeddMagwell :) I didn't ask why type of data you want store. It was more about where you want to store it. – kaiser Sep 1 '11 at 14:35

Assuming your Gallery Plugin is implemented using Post Types (standard or custom), I would recommend using Attachment post custom metadata.

However, I would strongly recommend that you look into hooking into WordPress' existing gallery/media-management implementation, rather than re-inventing the gallery wheel.

share|improve this answer
Really? Media Management is pretty crappy. You're right in general, but it's really ... crappy. – kaiser Sep 1 '11 at 14:34
Thus, the suggestion to filter it, to make it better. ;) Make the Gallery a Custom Post Type, and filter the Media Manager, to allow for inclusion of taxonomies and custom metadata. Best of all worlds. – Chip Bennett Sep 1 '11 at 14:42
Without thinking about it: Sounds good. And here goes the upvote. Btw: Join us in chat :) – kaiser Sep 1 '11 at 14:50
Unfortunately, chat is... finicky for me :) – Chip Bennett Sep 1 '11 at 14:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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