I actually have a PHP loop where I’m giving to each result a number, starting from 1 and following up in ascending order. The output is as follows:
1) article C
2) article B
3) article A
…but I’d like to reverse the list number, so I get something like:
3) article C (article’s order won’t change, they are descending, by date)
2) article B
1) article A
Here’s my current loop:
<?php
if (have_posts()) :
$counter = 1;
while (have_posts()) :
the_post(); ?>
<div>
<span class="count"><?php echo $counter; ?></span>
<?php the_title(); ?>
</div>
<?php
$counter++;
endwhile;
endif;
?>
Is there an easy way to do this?
Many thanks,
The WP_Query object has a variable holding the number of posts:
So your code can become: