2

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.

2 Answers 2

2

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.

2
  • Thanks, I want to store text data e.g. link to images, effect types, titles...
    – Marvin3
    Commented Sep 1, 2011 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
    Commented Sep 1, 2011 at 14:35
2

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.

4
  • Really? Media Management is pretty crappy. You're right in general, but it's really ... crappy.
    – kaiser
    Commented Sep 1, 2011 at 14:34
  • 1
    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. Commented Sep 1, 2011 at 14:42
  • Without thinking about it: Sounds good. And here goes the upvote. Btw: Join us in chat :)
    – kaiser
    Commented Sep 1, 2011 at 14:50
  • Unfortunately, chat is... finicky for me :) Commented Sep 1, 2011 at 14:52

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.