在元查询中搜索序列化值没有简单的方法。如果值列表不是很长,那么您可以设置多个元查询:
\'meta_query\' => array(
\'relation\' => \'OR\',
array(
\'key\' => \'system_power_supply\',
\'value\' => \'single\',
\'compare\' => \'LIKE\',
),
array(
\'key\' => \'system_power_supply\',
\'value\' => \'redundant\',
\'compare\' => \'LIKE\',
)
)
或者,如果您想获得超凡魅力,可以动态设置:
$values_to_search = array(\'single\', \'redundant\');
$meta_query = array(\'relation\' => \'OR\');
foreach ($values_to_search as $value) {
$meta_query[] = array(
\'key\' => \'system_power_supply\',
\'value\' => $value,
\'compare\' => \'LIKE\',
);
}