Last active
July 23, 2019 19:35
-
-
Save kodie/3f6235ba0854c21cf1f6ceb0c7542848 to your computer and use it in GitHub Desktop.
WordPress pagination indicator "Showing 20 – 29 of 138 posts"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$paged = max(1, (int) $wp_query->query_vars['paged']); | |
$first_post_index = $paged === 1 ? 1 : ((($paged - 1) * (int) $wp_query->query_vars['posts_per_page']) + 1); | |
$last_post_index = (($first_post_index + (int) $wp_query->post_count) - 1); | |
echo "Showing {$first_post_index} – {$last_post_index} of {$wp_query->found_posts} posts"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment