I have a simple query: $query = new WP_Query('showposts=5'); that will obviously display 5 latest posts. Is there any way to be able to get post’s position in the query? By position I mean… $query has 5 posts, and I need to be able to display the number of a post in the loop. I don’t really know PHP but I’m assuming the $query is an array variable (?) with these 5 posts.
It’s gonna be used in the JavaScript slider thing, where for every post I display a link like <a href="#1"></a> and I need that number to be 2 for the second post, 3 for the third etc.
Hope that makes any sense and someone will be able to help me.
Thanks in advance,
Justine
It’s not that hard (I copied the PHP-code of cpharmston):
You can use $i for #1, #2 etc. Everytime the while-loop has come to the end, $i++ makes sure it increments with one (so after the first time $i = 2 etc.).
Hope this helps 🙂 (I do think that cpharmston’s solution would be easier though).