wp_query item count
Use the following code to count the total items using WordPress wp_query:
$query = new WP_Query( $args );
$count = $query->found_posts;
Explanation:
1. Create a new instance of WP_Query class using $query = new WP_Query( $args );
.
2. Retrieve the total number of posts found by the query using $count = $query->found_posts;
.