Counting Posts of a Given Post Type Having a Specific Taxonomy?

Somatic had the cleanest answer, but missed one thing. You should specify the numberposts to be -1 so that it counts them all. Like this:

$args = array(
    'post_type' => 'artwork',
    'post_status' => 'published',
    'genre' => 'romantic',
    'numberposts' => -1
);
$num = count( get_posts( $args ) );

just replace genere with your taxonomy slug and romantic with the specific term.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)