我的帖子中有一个自定义字段,名为" position" ,实际上我使用ACF复选框创建它并返回一个数组。现在我想查询这个自定义字段过滤的帖子,这样如果值" x"在自定义字段中然后显示帖子。我试过这段代码,但它没有用:(
$posts_sabet_1 = new WP_Query(
array(
'post_type' => 'sabet',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'position', // array
'value' => 'top', // is "top" in "position" field?
'compare' => 'LIKE' // I also tried "IN" , "=" , "RLIKE" . none of them worked
)
)
)
);
答案 0 :(得分:0)
你尝试过这样的事吗?
$posts_sabet_1 = new WP_Query(
array(
'post_type' => 'sabet',
'posts_per_page' => -1,
'meta_key' => 'position'
'meta_value' => 'top'
)
);