Show post numbers
-
Hi,
I want to show the current post number on the total post.
For exemple, in category “Z” I have 5 posts. I would like to show something like this :
Post 1 of 5 in category Z
Firstly, I used this function to get the total posts of my Z category:
[Code moderated as per the Forum Rules. Please use the pastebin]
And on my file, I placed this line of code :
wt_get_category_count();
After, I needed to count the current post… I used this little function to achived it :
[Code moderated as per the Forum Rules. Please use the pastebin]
With this function, I placed this part of code to render the “Page x of” :
<?php $currentID = get_the_ID(); ?> <?php $currentNumber = Get_Post_Number($currentID); ?> <?php echo 'Page '.$currentNumber.' of'; ?>
At this point, evertything works pretty fine execpt one thing… If I’m on the first post, I get this
Page 1 of X
(correct)… But, if I’m on the last post count, I’m getting something likePage 0 of X
like if in the function, the last post get a replace for the value of 0.Can some 1 tell me how I could replace the “0” by the last number?
Here is what it looks like :
<span class="post_info">Page <?php echo $currentNumber.' of '.wt_get_category_count(); ?></span>
Page 1 of 5
Page 2 of 5
Page 3 of 5
Page 4 of 5
Page 0 of 5
- The topic ‘Show post numbers’ is closed to new replies.