Support » Fixing WordPress » Displaying individual and total number of posts

  • Hi,
    I wish to add a post number and then a total number of posts in each post written, i.e.
    = “This is test message 1 of 5” where the 1 is the post number and the 5 is the total number of posts.

    I understand that mySQL gives each post a unique ID which can be displayed using <?php echo $post->ID; ?> but this is always increasing even if posts are deleted.

    I wish to reassign a post with the number 1 even if it it is post 33 and all of the other posts have been deleted, is there a widget or some php code that could check for non-deleted posts in a category and assign them a number always starting from 1 (with 1 being the oldest)?
    Then display this number in the post head or body along with the total number of non-deleted posts in this category?

    Then when a new post is added the process is started again so post 1 is now post 2 etc

Viewing 7 replies - 1 through 7 (of 7 total)
  • Assuming you want to put that in a Category Template, you could use get_categories to retrieve the information that would include the total posts in a category, then in your post loop, use a counter to increment a number that would represent the post number.

    Hi MichaelH,
    Many thanks for the info.
    I’m new to WordPress and PhP and I do not have a clue how I would be able to add a counter to the loop, it all looks a bit daunting atm.

    I would be grateful for any help you can offer.

    Since you are new, then I’d recommend getting your blog setup and see if you live without them.

    I have set-up WordPressMU with 10 blogs.
    I think ‘blogging’ could be a great tool for our establishment (education) and see great potential in offering a blog as our electronic messaging system.
    I have set-up a test message system:
    This system is a blog with the J Post Slider plugin, each post is then scrolled in/out and an image is faded in/out behind.

    A computer is pointed the URL and then hooked up to big display screens. I have removed the status bar in IE and am using the full screen feature (F11). I have also added a refresh to the meta so the whole system will refresh after a few minutes.
    This works, but I wish to tweak it slightly so the viewer has an idea on how many messages will scroll through and which message they are currently viewing.

    The total number of messages will change as old messages are removed and new ones added, however I wish to use a numbering system from 1 rather than <?php echo $post->ID; ?> which is the mySQL post number.

    I’m not too sure of the php bit needed for the numbering but it must be possible to do?

    I would be grateful for any help

    I have set-up WordPressMU with 10 blogs.

    Wonder if there’s a solution at the MU support forums:

    Just as a note, there is an email list for people using WordPress in an education environment:

    Hi MichaelH
    Many thanks for the forum and list info I will subscribe to these

    hi, did you find a solution for incrementing/counting the posts?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Displaying individual and total number of posts’ is closed to new replies.