WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the best way to display the appearance number of a post in a query?

For example, if a post is the first listed print #1. If it is third, print #3.

Any direction is appreciated!

share|improve this question
start a counter before The Loop, display the value of the counter in the loop. – Nicholas Pickering Feb 21 '13 at 23:12
up vote 4 down vote accepted
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) :
    echo('#' . $the_query->current_post + 1); // $the_query->current_post has the index
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.