Project Detail

use php to assign numbers to paged wordpress posts  

use php to assign numbers to paged wordpress posts is project number 413956
posted at Freelancer.com. Click here to post your own project.

 

| More Free Trial For New Buyers
 

Status:

Selected Providers: BirdWatcher

Budget: $30-250

Created: 04/05/2009 at 21:14 EDT

Bid Count: 4

Average Bid:
$ 53

04/08/2009 at 21:14 EDT

Project Creator: amgaf
Employer Rating: 10/1010/1010/1010/1010/1010/1010/1010/1010/1010/10 (9 reviews)

Bid On This Project
 

Description

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.

Job Type

Messages Posted:0 View project clarification board Post message on project clarification board

Bid On This Project
 

If you are the project creator or one of the bidders Log In for more options

 

120

3 days

04-05-2009 21:48 EDT

Please see PMB.

help

 

30

0 days

04-06-2009 01:28 EDT

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

help

KMZ

 

30

0 days

04-06-2009 00:01 EDT

Hi Try changing this line to this hope this helps Alex

help

 

30

1 day

04-06-2009 01:19 EDT

hello, i can help you getting this out. thanks

help


    Bid on this Project