特定のメタ キー値が存在する投稿の数を数えようとしています。この場合、値が「ソフト」のキー「テクスチャ」を持ち、「赤」であるキー「色」も持つ投稿です。青」または「緑」。
私のコードはエラーにはなりませんが、前述のメタ キー値を持つ投稿だけではなく、すべての投稿をカウントしているようです。
$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;
私は何を間違っていますか?
乾杯。