// get post count of all "ticket" CPT posts function bl_get_ticket_count() { $args = array( 'post_type' => 'ticket', 'posts_per_page' => -1, 'fields' => 'ids' ); $query = new WP_Query( $args ); return $query->post_count; } // get post count of all "ticket" CPT posts that have a "ticket_status" (taxonomy) of "open" (term) function bl_get_open_ticket_count() { $args = array( 'post_type' => 'ticket', 'posts_per_page' => -1, 'fields' => 'ids', 'tax_query' => array( array( 'taxonomy' => 'ticket_status', 'field' => 'slug', 'terms' => 'open' ) ) ); $query = new WP_Query( $args ); return $query->post_count; } // get post count of all "ticket" CPT posts that have a "ticket_status" (taxonomy) of "closed" (term) function bl_get_closed_ticket_count() { $args = array( 'post_type' => 'ticket', 'posts_per_page' => -1, 'fields' => 'ids', 'tax_query' => array( array( 'taxonomy' => 'ticket_status', 'field' => 'slug', 'terms' => 'closed' ) ) ); $query = new WP_Query( $args ); return $query->post_count; }