Show post counter like this: 1-10 of 50, 11-20 of 50 etc

I wan’t to make a post result counter that looks/works like this:

1-10 of 45 results

41-45 of 45 results

I know I can count currently displayed posts with $wp_query->post_count and the total amount of posts with $wp_query->found_posts

The total result is obviously easy, but I don’t know how to correctly display the 1-10, 11-20, 41-45 and so on.

I’ve found this:

$args = array(
‘posts_per_page’ => 10,
‘paged’ => $paged
);
query_posts($args);

$startpost=1;
$startpost=10*($paged – 1)+1;
$endpost = (10*$paged < $wp_query->found_posts ? 10*$paged :
$wp_query->found_posts);

However it’s not really working. I wan’t to tap into the global $wp_query

Read more here:: Show post counter like this: 1-10 of 50, 11-20 of 50 etc

Leave a Reply

Your email address will not be published. Required fields are marked *