Niekje
Member
Posted 7 months ago #
Hi everyone,
For some while now I have been trying to find a solution for the following: On top of my blogpage I want to show how many posts that current page is showing, so lets say the page has 9 posts I want the page to return viewing post 1 to 9 from 28 total.
Also when you use the post/page navigation going for example to: http://www.myblog.com/myblog/page/2/ it should say post 9 to 18 from 28 total.
I wonder if anyone has ever done something like that and would like to share it with me, I greatly appreciate it.
Kind regards
The WP PageNavi plugin will do at least part of what you want.
try this code:
<?php
echo 'post ' . (1+get_query_var('posts_per_page')*(get_query_var('paged')?get_query_var('paged')-1:0)) . ' to ' . ($wp_query->post_count+get_query_var('posts_per_page')*(get_query_var('paged')?get_query_var('paged')-1:0)) . ' of ' . $wp_query->found_posts . ' total';
?>
uses:
get_query_var('posts_per_page') = your settings under dashboard - settings- - reading - Blog pages show at most [ ] posts;
get_query_var('paged') = which paginated page you are on
$wp_query->post_count = the actual number of posts on this paginated page;
$wp_query->found_posts = number of all posts for this query.
Niekje
Member
Posted 7 months ago #
Thanks allot alchymyth, I really appreciate the help.
I tried out your code and it works fine for normal WordPress 'posts'. Now I only need to figure out how I can set it up to work with the WordPress Shopp plugin. As far as I know that plugin does not use the normal '$wp_query' but I will check that out later.
@vtxyzzy thanks for your answer but I know that plugin and it does not do what I need.
Kind regards