Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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.