Count posts with meta value
<p>I'm trying to show the number of posts that have certain <code>meta key</code> <code>values</code> for the current user.</p>

<p>This is my code:</p>

<pre><code>    $args = array(
    'posts_per_page'    =&gt; -1,
    'post_type'         =&gt; 'post',
    'post_status'       =&gt; 'publish',
    'author'            =&gt; $current_user_id,
    'meta_query'        =&gt; array(
           'key'        =&gt; 'color',
           'value'      =&gt; array('red', 'blue')
    ),
);
$posts_array = get_posts( $args );
$the_count = count($posts_array);

echo $the_count;
</code></pre>

<p>Thi is counting <strong>ALL</strong> posts for the current user, ignoring the <code>meta key</code> <code>values</code>.</p>

<p>I only need the <code>$the_count</code> to be the number of posts that have a <code>meta key</code> <code>value</code> <code>'red'</code> or <code>'blue'</code> for the current user.</p>

<p>What am I doing wrong?</p>

<p>Thanks in advance!</p>