contagem de itens wp_query
<?php $count = $custom_posts->found_posts; ?>
Wandering Walrus
<?php $count = $custom_posts->found_posts; ?>
$args = array('post_type' => 'post',
'posts_per_page' => '4',
'paged' => $pagination);
$posts = new \WP_Query( $args );
echo $posts->post_count; // echo number of posts on query
// If you what to know if you arrived to pagination end then:
if ($posts->max_num_pages == $pagination) echo "You are on an end page";