我想要写一个查询,它根据我添加的元键获取数据。元密钥名是“中继器”。
这是我的贴子。
序列化:
a:3:{i:0;a:3:{s:9:"postdates";s:10:"2021-02-02";s:12:"postplatform";a:1:{i:0;s:3:"3DS";}s:10:"postregion";a:2:{i:0;s:2:"EU";i:1;s:2:"JP";}}i:1;a:3:{s:9:"postdates";s:10:"2021-02-03";s:12:"postplatform";a:2:{i:0;s:3:"3DS";i:1;s:2:"DS";}s:10:"postregion";a:2:{i:0;s:2:"EU";i:1;s:2:"JP";}}i:2;a:3:{s:9:"postdates";s:10:"2021-02-04";s:12:"postplatform";a:3:{i:0;s:3:"3DS";i:1;s:2:"DS";i:2;s:27:"MAC, Linux, Mobile And More";}s:10:"postregion";a:3:{i:0;s:2:"EU";i:1;s:2:"JP";i:2;s:2:"NA";}}}未序列化:
Array
(
[0] => Array
(
[postdates] => 2021-02-02
[postplatform] => Array
(
[0] => 3DS
)
[postregion] => Array
(
[0] => EU
[1] => JP
)
)
[1] => Array
(
[postdates] => 2021-02-03
[postplatform] => Array
(
[0] => 3DS
[1] => DS
)
[postregion] => Array
(
[0] => EU
[1] => JP
)
)
[2] => Array
(
[postdates] => 2021-02-04
[postplatform] => Array
(
[0] => 3DS
[1] => DS
[2] => MAC, Linux, Mobile And More
)
[postregion] => Array
(
[0] => EU
[1] => JP
[2] => NA
)
)
)现在,如果POST日期是今天/特定日期,我想获取该帖子。
谢谢你,阿里
发布于 2021-02-02 13:36:13
要解决这个问题,您需要将要查询/筛选的日期存储为单独的post元键/值对。值需要是字符串/数字/布尔值,才能以这种方式查询。它们不能是复杂的结构或子字符串,例如JSON、数组、对象。
还请注意,保存数组或对象是一种安全风险。这是因为您无法保存数组/对象,因此WordPress使用serialize函数将其转换为字符串。这会使您面临对象反序列化攻击。
https://wordpress.stackexchange.com/questions/382648
复制相似问题