23 May, 2004
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.
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.
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?
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.