Querying a meta_value of type array
-
Hi,
I’m in the process of creating my own custom post type plugin, and I’m currently pondering the best way to save my own post type’s metadata to the database.
On one hand, it’s benificial to divide all meta data over multiple keys. For example, when integrating an
event
post type with astart date
and anend date
attribute, you could choose to save both of these separately by invoking yheupdate_post_meta()
method twice for two different meta keys. It costs a bit of database space, but it’s easy to query later on (e.g. https://codex.www.ads-software.com/Class_Reference/WP_Meta_Query).On the other hand, you could choose to save these
date
attributes in the database as an array, thus using only one key. But then, you can’t really use theWP_Meta_Query()
easily in a later stage.Which would be best when you have, say, 20 attributes: storing them all 20 separately, or splitting them among (less than 20) meta keys as arrays?
- The topic ‘Querying a meta_value of type array’ is closed to new replies.