Is there a way to get a number of items within Wordpress loop code:
This loop lists the p
You can use the post_count property of $WP_Query
, like so:
$wp_query->post_count
Be aware of the difference with found_posts
, which counts the posts which, though matching the query, are not being displayed (e.g. for pagination). You might want to use one or the other depending on your particular situation.