O-ded
O-ded

Reputation: 57

WordPress Count Taxonomy Posts + Filters

I want to count taxonomy posts by those filters:

Here is my code:

<?php
$args = array(
   'post_type' => 'show',
   'meta_key' => 'done',
   'meta_value' => 'no',
   'taxonomy' => 'comedian',
            'field'    => 'term_id',
            'terms'    => '2',
);
$myquery = new WP_Query($args);

echo "Found: $myquery->found_posts";
?>

This code filter well "shows", "done" and "comedian" but its not filter for Term ID 2 only... What I did wrong with my code?

Upvotes: 1

Views: 728

Answers (1)

Yan Foto
Yan Foto

Reputation: 11388

See the documentation you should have something like this:

$args = array(
   'post_type' => 'show',
   'meta_key' => 'done',
   'meta_value' => ''.$overyet.'',
   'tax_query` => array(
                    'taxonomy' => 'comedian',
                    'field' => 'term_id',
                    'terms' => 2
                  )
);

Upvotes: 1

Related Questions