admin管理员组

文章数量:1304199

I have a poll functionality that uses custom post type & taxonomy to define actual polls.

CPT: poll_entity

Taxonomy: poll_year

Now I need to store votes on user to highlight on voting page. I'm saving as serialized array to voted_for meta key.

Currently it looks like:

[
   2020 => [1, 2, 5] // (id of chosen poll custom post / voting entity),
   2021 =>  [2, 4, 5]
]

While it's working fine, I'm wondering if it's a bad practice and if there is a better way to store hierarchies like that?

本文标签: Arrays in custom fields or is there a better way