Finding ordinal post (not ID) number?
-
My apologies if this has been answered anywhere already- if it has, I couldn’t find it.
I am using WP to run a regular blog and a separate ComicPress installation. I am creating a standard kind of webcomic navigation (First/ Previous/ Next/ Latest), using graphics that will change depending on whether or not there is a next or previous page to go to. For example, if I have 10 posts and the reader is on page 5, their nav will look like this:
[<<] [<] [>] [>>]
But if they are on post 10 of 10, it will be:
[<<] [<] > >>
…meaning that the last 2 buttons are disabled because there is nowhere further to go. I plan to determine this by comparing the total # of posts with the post number. I have found a way to obtain the total # of posts in a category:
<?php $cat_count = $wpdb->get_var(“SELECT category_count from $wpdb->categories WHERE cat_ID = ‘2’”); ?>
<?php echo $cat_count ?>But I cannot find a simple way to return a simple ordinal number for a given post. All I can get is the post ID, which as you know, could well be greater than the actual post number.
Is there any way to figure out a post number (ordered by date)? Or should I be taking another approach entirely to this and forget those scripts I used to hack together in Javascript? I am a complete PHP noob so any help would be appreciated.
To see what I am talking about, you can go to https://www.entropiacomics.com
- The topic ‘Finding ordinal post (not ID) number?’ is closed to new replies.