最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Arrays in custom fields or is there a better way?

programmeradmin0浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论