0
我想要计算某些元键值存在的帖子数量,在这种情况下帖子的值为'soft'的键值为'texture',而且有一个'红色','蓝色'或'绿色'的关键'颜色'。基于多个元键值对帖子进行计算
我的代码没有错误,但它似乎算所有职位,而不是只是那些与元键值提到:
$args = array(
'posts_per_page' => -1,
'post_type' => 'post',
'post_status' => 'publish',
'author' => $current_user_id,
'meta_query' => array(
'key' => 'texture',
'value' => 'soft'
),
array(
'key' => 'colours',
'value' => array('red', 'blue', 'green')
)
);
$posts_query = new WP_Query($args);
$the_count = $posts_query->post_count;
echo $the_count;
我在做什么错?
干杯。
我早就预料到的工作,但它仍然被所有帖子。 – user3256143
@ user3256143查看我更新的答案。 –
是的,我已经 - 除非您更新后再次更新它? – user3256143