复选框字段存储为serialized array, 因此,您不能使用IN
运算符和数组以及您要查找的值。
要获取选中“墨尔本”的帖子,请更改meta_query
收件人:
$meta_query = array(
array(
\'key\' => $name,
\'value\' => \'"melbourne"\',
\'compare\' => \'LIKE\',
)
);
获取帖子的步骤
melbourne
或
sydney
:
$meta_query = array(
\'relation\' => \'OR\',
[
\'key\' => $name,
\'value\' => \'"melbourne"\',
\'compare\' => \'LIKE\',
],
[
\'key\' => $name,
\'value\' => \'"sydney"\',
\'compare\' => \'LIKE\',
],
);
考虑改变解决方案,因为
these types of queries negatively affect performance.