Support » Fixing WordPress » auto-increment counter

  • where can I find an auto-increment counter for wordpress?
    I want it to returns a number that is incremented each time this tag is called.
    so that I can count the front-page posts.. identifying them as
    <div id=’post1′>
    <div id=’post2′>
    <div id=’post3′>
    <div id=’post4′>
    and so on.. automaticaly..

    how can i do that?

    thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • it’s built in

    $wp_query->post_count is the # of posts on the page

    $wp_query->current_post is the # of the current post on the page

    current post starts at zero, post_count starts at 1


    I personally refer you to go with the statcounter plugin for statistics for your can download it from here:


    Shane G.


    i undestand that the <?php the_ID(); ?> tag does the counting automatically.
    but its count is very strange.. cause it goes from 49 on the first post to 43 on the second post.

    what i really need is a simple increasing id number.. starting from 0.
    exactly like this:
    <div id=’post0′> for post one (most recent post)
    <div id=’post1′> for post two

    <div id=’post9′> for post ten (last post of the page)

    i know that textpattern has a plugin called rvm_counter that does this like a charm. but I wanted something for wordpress.

    how can I add this on the loop? is that possible on wordpress?

    thanks in advance.

    oh, i got it now.

    i wrote <div id=”post<?php echo($wp_query->current_post + 1); ?>”> to the loop and it worked.

    thanks! 🙂

    Is it posible to show count from last one ?
    post 11
    post 10

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘auto-increment counter’ is closed to new replies.