Wordpress: How to paginate a list generated by PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
braaad
Forum Newbie
Posts: 4
Joined: Mon Sep 06, 2010 6:31 pm

Wordpress: How to paginate a list generated by PHP?

Post by braaad »

'm using a Wordpress plug-in called WP Calendar to display a list of events. It's a plug-in that I activated in the admin and then added the PHP code below to my template file. Currently, the plug-in is set to display 20 events, however, I need to display 100+ events so I would like to paginate this list. Does anyone here have any pointers or links to tutorials on how to do this? Thank you!

Code: Select all

<?php fse_print_events_list(
  array( 'number'   => 20,
         'before'   => '<div class="calendar">',
         'after'    => '</div>',
         'template' => '<h1>{event_startdate}</h1><h3>{event_subject}</h3><p>{event_description}</p><br />'
  )
);

?>
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Wordpress: How to paginate a list generated by PHP?

Post by Jonah Bron »

braaad
Forum Newbie
Posts: 4
Joined: Mon Sep 06, 2010 6:31 pm

Re: Wordpress: How to paginate a list generated by PHP?

Post by braaad »

Thanks for the link. I read through it thoroughly, tried to hack it to my needs and utterly failed :roll:
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Wordpress: How to paginate a list generated by PHP?

Post by Jonah Bron »

What doesn't work? Do you get an error?

BTW, in programming, failure is not an option. :)
braaad
Forum Newbie
Posts: 4
Joined: Mon Sep 06, 2010 6:31 pm

Re: Wordpress: How to paginate a list generated by PHP?

Post by braaad »

Ha ha, that's a great attitude! Well, since you asked, I have to admit it's basically my lack PHP coding fundamentals other than cutting'n'pasting, plugging in some values into an array, and basically stumbling around trial'n'error style till it works. The link you posted is great but honestly it's a bit over my head- I don't even know where to start.

It's kind of like someone asking how to make a wedding cake but they've only made cupcakes... using a Barbie oven. I was hoping there was ab easily modifiable bit of code that I could hack into what I have, but this isn't the case. I will probably end up hiring someone to do it. Are you available? 8)
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Wordpress: How to paginate a list generated by PHP?

Post by Jonah Bron »

Actually, a quick and easy alternative would be to change the little bit of code to make the div.calendar have a fixed height and set the overflow to scroll. Then just change the 'number' to 100+ or whatever you want.

Just insert this CSS into the calendar class:

Code: Select all

height: 300;
overflow: scroll-y;
If you're really bent on pagination and can't do it yourself, yes I'm available.
braaad
Forum Newbie
Posts: 4
Joined: Mon Sep 06, 2010 6:31 pm

Re: Wordpress: How to paginate a list generated by PHP?

Post by braaad »

Nice work-around! Going to present it to the client and see what they think. If they're not into it, I'll PM you regarding your rates. Thank you Jonah!
Post Reply