use php to assign numbers to paged wordpress posts

Completed Posted Apr 5, 2009 Paid on delivery
Completed Paid on delivery

Hi, I'm trying to work out the code to add an increasing number in front of each wordpress post as they are displayed over several pages. I was hoping to show 10 posts per page.

Page 1 show 1 - 10

page 2 shows 11 - 20 and so on

I've got so far. Created a variable which increases in each iteration of The Loop. eg.

<?php $counter = 1; ?>

<?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?>

... skipping some code ...

<h1>#<?php echo $counter; ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?> blurb"><?php the_title(); ?></a></h1>

<?php $counter++; ?>

Works fine if I have all the posts on one page but as soon as I split it over two pages the second page starts again with the first post showing 1 - not 11.

I believe WordPress keeps the page number in a variable called $paged, and I think I need to global $paged and add ($paged * num_per_page) to the counter but being a php dunce it's all a bit beyond me.

I'm hoping someone can give me the exact code I need to use. Probably only a two minute job if you know what you're doing.

Thanks.

PHP

Project ID: #413956

About the project

3 proposals Remote project Active Apr 6, 2009

Awarded to:

BirdWatcher

Hello! I can do it for You for only $30. It will take me no longer than 1-2 hours from now. IF You choose me I will do my best to do it as soon as possible. I can start immidiately. best regards Birdwatcher

$30 USD in 0 days
(62 Reviews)
7.4

3 freelancers are bidding on average $30 for this job

thcoder

hello, i can help you getting this out. thanks

$30 USD in 1 day
(34 Reviews)
6.8
KMZ

Hi Try changing this line to this hope this helps Alex

$30 USD in 0 days
(45 Reviews)
5.5