using text list field to save meta to the db

Support General using text list field to save meta to the dbResolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #28173
    @mindspark@mindspark
    Participant

    I'm building a field group that tracks company equipment. I'm collecting several pieces of information for each item like:

    • Brand
    • Color
    • Serial #

    The question is -

    If I collect these meta using either a text list field or fieldset text field, is that meta save in the db, and can it be queried later?

    #28189
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Yes, it is possible to query by meta value. But for some specific field types like fieldset_text or group, the value stored in the database is a serialized array and it very hard to query by this value. You need to use another plugin to do that, read more here https://metabox.io/searchwp-metabox-integration/.

    For simplicity, I recommend using text field to save the data to get easier when querying.

    #28193
    @mindspark@mindspark
    Participant

    So if I use a text list field (not fieldset and not group) then the meta is saved and related to the post?

    #28205
    Long NguyenLong Nguyen
    Moderator

    Hi,

    All the field values (meta) are stored in the database and assigned to a post. See more here https://wordpress.org/support/article/custom-fields/

    But it's very hard to query by value in a serialized string. You can read the query by meta value on the documentation https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters

    #28230
    @mindspark@mindspark
    Participant

    sorry for this clarification - are you saying that field meta for all 3 of these field types is serialized?

    • list field text
    • fieldset text
    • group

    or only

    • fieldset text
    • group

    Thanks

    #28234
    Long NguyenLong Nguyen
    Moderator

    Hi,

    • Text List (cloneable)
    • Fieldset Text
    • Group

    will save data in a serialized array. You can see on the documentation
    https://docs.metabox.io/fields/text-list/#data
    https://docs.metabox.io/fields/fieldset-text/#data

    You can also read more on this article to choose the custom fields or custom taxonomies for query posts.
    https://metabox.io/custom-fields-vs-custom-taxonomies/

    #28244
    @mindspark@mindspark
    Participant

    Thank you!

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.