Viewing 2 reply threads
  • Author
    Posts
    • #7565
      Stephen
      Participant

      Hi I am new to Piklist and just getting started, and I have a question about grouped fields (and pulling their data out on the front end). If I don’t store as a serialized group, but rather as individual post_meta fields, how on the front end will I be able to associate those elements?

      For example, say I have a record with several name and address pairs that go together (but are separate fields), will those always be stored in the same order in the db or is there some other identifier that ties them together if they are not stored in a serialized array (grouped)?

    • #7566
      Jason
      Keymaster

      Hi @ssuess!

      Welcome to Piklist!

      Groups are the recommended way of creating a collection of field data. You simply pull the group field and, voilà, you have all the associated data. If it’s an Add More, then you can be sure the data is paired together correctly.

      A fun fact, however, is that it is possible to make a group field, but then not provide a 'field' attribute to the group. What that does is stores all the child fields separately, as if they were individual. You can even make this an add_more and the meta will be stored in the right order so the index is correct for the related fields.

      The only time it really makes sense to store associated data separately is if you intend on doing queries based on the value of individual meta. Say, for example, you had an address group, but you wanted to be able to pull in your posts limited to a specific country, then you’d want to store them separately. Otherwise you’d have to search within the serialized data in the query, which is rather suboptimal.

      Hope this helps! 🙂

    • #7568
      Stephen
      Participant

      That does help Jason, Thanks!

Viewing 2 reply threads
  • The topic ‘Grouped vs not grouped’ is closed to new replies.