WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Iam using wordpress numbered pagination function, it works good I have around 800 posts on homepage, every page i show 8 posts.

So when the user clicks on pagination i want to show 1-8 of 800. 1st post out of 8 total 800 then user clicks 2nd page - i want to show 9-16 of 800 how to implement i researched a lot.

share|improve this question
up vote 3 down vote accepted
 * Display pagination information in the format "X - Y of Z".
 * @param object $wp_query Optionally generate string from custom query, defaults to main.
function wpse_106121_posts_count( $wp_query = null ) {
    if ( ! $wp_query )
        global $wp_query;

    $posts = min( ( int ) $wp_query->get( 'posts_per_page' ), $wp_query->found_posts );
    $paged = max( ( int ) $wp_query->get( 'paged' ), 1 );
    $count = ( $paged - 1 ) * $posts;

        '%d - %d of %d',
        $count + 1,
        $count + $wp_query->post_count,

Place the above in your functions.php, then call it where you'd like to display the text:

<?php wpse_106121_posts_count() ?>
share|improve this answer
Works Perfectly thank you – Shabbir Lakdawala Jul 11 '13 at 11:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.