I'm trying to count the number of posts where certain meta key values exist, in this case posts that have a key 'texture' with the value 'soft', and also have a key 'colours' that are 'red', 'blue' or 'green'.
My code does not error, but it appears to count all posts instead of just the ones with the meta key values as mentioned:
$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;
What am I doing wrong?
Cheers.