scriptygoddess

23 May, 2004

wpPaginate

Posted by: Jennifer In: WordPress Plugins

This plugin is designed to paginate your pages (similarly the way the mt-paginate plugin worked). See instructions/information below. (Again – I'm still a WP-newbie – so there may be updates as people use this, and give me feedback. Please check this post to see updates)

Current Version: v. .1.1
Last Updated: 8/18/04 3:34 PM EST
IMPORTANT: Future development on this version has ceased. The latest version of this plugin (compatible with WP 1.5) can be found here.

Step 1
Download and install this plugin
(Same as always: right-click and save that file with a .php extension. Then upload it to your plugins directory, which is located in your wordpress folder: wp-content/plugins. Don't forget to activate it in the plugins page in the WP admin interface)
Important: make sure you do not have any spaces before the first <?php or after the last ?> in your copy. These spaces will cause "cannot modify header…" type errors.

Step 2
Call the paginate function on your page after wp-blog-header, but before the "The Loop" (doesn't matter where):

<?php wpPaginate(); ?>

Then wherever you want to show your navigation put this:

<?php print_pg_navigation('<p><b>','</b></p>'); ?>

Really, at this point, you're good to go. If you want to tweak, change, etc. etc. I've included the rest of this information.

Step 3 (Optional)
wpPaginate is where most of the customizing is done for how the navigation will work. This function's signature looks like this:

wpPaginate($paginateAfterNposts = ", $pageNavDivider = ' | ', $paginateHome = FALSE, $briefnavigation = TRUE, $navpad = 6)

So, here is an explanation of the arguments shown above that you can pass into the wpPaginate() function:

$paginateAfterNposts – Number of posts per page during pagination. Value should be a number. Default is whatever you have your "posts per page" set to in the admin interface. To leave it set at the default, enter in " here. (that's two single quotes with nothing in between)

The reason I put this in the function is because if on your paginating pages, you want them more or less than you normally do.

This value will not change the number of posts the page is grabbing to start with. For example:

If you set your "posts per page" to be 20 – your home page will always grap the last 20 posts. We're just manipulating what to do with those 20 posts.

However, when you have the page grabbing all the posts for a particular archive (ie monthly archives, category archives, search results) – then that posts per page is ignored and it will return ALL the posts for that particular archive. That's where this whole plugin is most useful!

$pageNavDivider – Text to put in between your page numbers. Value should be text within single quotes. Default is ' | '

$paginateHome – Paginate your home page? Value should be TRUE or FALSE. Default is set to FALSE

In this latest version I simplified this part. This was really what I was intending, but previously, I just made it more complicated than it needed to be. I can't see a reason why someone would want to paginate their home page – but I wanted to build in that flexibility.

$briefnavigation – Truncate navigation? Value should be TRUE or FALSE. Default is set to TRUE.

If you have many many pages – which would have resulted in a long list of pagination links, this will truncate them to show only a certain number (certain number setting see below)

$navpad – How many navigation links on either side of the current page should be displayed Value should be a number Default is 6.

Extra – if, on a paginated page, you want to see all posts – change offset=(some number) in the URL you'll get to offset=all. Do people see value in adding this as an option in the function call, so you can have it show up in the navigation?

Change Log:
new in ver .1.1
Made truncating feature part of the main wpPaginate function call (rather than have people edit the actual plugin)

new in ver .1
Now has the ability to truncate the list of pagination links if there are too many. This can be turned on/off in the plugin, as well as customized for how many links you want to display on either side of your current page. (This addition thanks to Stan Schwarz)

new in ver .03
Added "before" and "after" parameters to show page navigation function.

new in ver .02.3
Fixed a few more bugs relating to the ? and & (and searches that had no results)

new in ver .02.2
fixed bug with ? & thingy (see comments) (via Entropy)

new in ver .02.1
fixed left over comment (via Entropy)
fixed issue with "all" view – now just returns instead of continuing logic. (via Entropy)

new in ver. 02:
1-change last variable to be TRUE / FALSE on paginating your "home" page.
2-printing the navigation is now a seperate line – and can be duplicated anywhere and as often on the page as you like.

102 Responses to "wpPaginate"

1 | Jack

January 18th, 2005 at 5:44 pm

Avatar

"…I have the best of intentions to…"

I know you have :), so I'll have to be patient, for me not so into phpee :(.

2 | Jennifer

January 23rd, 2005 at 5:44 pm

Avatar

Ok ok! We got a ton of snow here and I had nothing better to do so – I've updated the plugin for WP 1.5. For those of you that are subscribed to comments here – I'm closing comments down here and all information about the updated plugin can be found here.

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements