A handy, extensible class for paginating your custom post type lists.
Author: | Boone B Gorges (profile at wordpress.org) |
WordPress version required: | WordPress |
WordPress version tested: | WordPress |
Plugin version: | 1.1 |
Added to WordPress repository: | 15-05-2011 |
Last updated: | 02-05-2012
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
|
Rating, %: | 0 |
Rated by: | 0 |
Plugin URI: | http://github.com/boonebgorges/boones-paginat... |
Total downloads: | 1 532 |
Click to start download |
Here’s how I recommend using the class.
- Either activate this plugin, or include the class in your own plugin file.
- When you start to render the page with the post list, instantiate the pagination class, using an argument array if you’d like: $pargs = array( ‘get_per_page_key’ => ‘perpage’, ‘get_paged_key’ => ‘current_page’, ‘per_page’ => 15 ); $pagination = new BBG_CPT_Pag( $args );
- When constructing your query arguments (for query_posts() or WP_Query), you can use the class to get your pagination arguments out of the $_GET parameters. For instance: $args = array( … ‘posts_per_page’ => $pagination->get_per_page, ‘paged’ => $pagination->get_paged … ); query_posts( $args );
- After firing the query, use the
setup_query()
method to populate the rest of the class. If you usedquery_posts()
, you don’t need an argument: $pagination->setup_query(); If you usenew WP_Query
, you’ll have to pass the query object: $my_query = new WP_Query; $pagination->setup_query( $my_query ); - Then you can use all sorts of fun methods, like $pagination->paginate_links(); $pagination->currently_viewing_text();
ChangeLog