Snippets

Rik Kendell Posts per page

Created by Rik Kendell
<?php 
// Show current post range, and total number of posts
// i.e: "Showing 9 - 16 of 21"
    $page  = max( 1, get_query_var( 'paged' ) );
	$postsPerPage   = get_query_var('posts_per_page');
	$start = $postsPerPage * ( $page - 1 ) + 1;
	$end   = $start + $wp_query->post_count - 1;
	$total = $wp_query->found_posts; 
?>

<p><?php echo 'Showing ' . $start . ' - ' . $end . ' of ' . $total; ?></p>

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.