WordPress Pagination Class

I wrote a simple, yet extremely useful WordPress pagination class. The class is not complete yet, and I work on it as I move along and need new features or actions. So you have the freedom to take the class and customize/expand it as you might need to. First off, you can download the class below :

WordPress Pagination Class

In order to use the class, you’ll need to include the class file. With the class file included, you can initialize the class and then execute the startPaging() class method. Before you execute the method, you need to specify some variable values. See the example below :

include_once(ABSPATH . 'wp-content/plugins/yourplugin/class.pagination.php');
$tableName = $wpdb -> prefix . 'yourplugintable';
$tableFields = '`id`, `title`, `description`';
$pagination = new Pagination($tableName, $tableFields);
$pagination -> perPage = 10;
$pagination -> pluginUrl = '?page=yourplugin.php&';
$allRecords = $pagination -> startPaging($_GET['wpMailinglistPage']);

From there, you can simply loop through your records with a foreach(); or something similar to output the records. In order to output the page numbers/links and the “previous”/”next” links, you can echo the pagination(); class method. See the example below :

 pagination(); ?>

Good luck! I hope this is useful!
Please feel free to post your updated source code, ideas and comments.


  1. Sergio Ordonez on September 29, 2009

    Hello Antonie, I´m using Fresh News theme too and I´m looking for a pagination plugin.

    I found WP Page navi but I have an issue, all the pages paginated point to the home page. I have heard it´s because it´s a custom theme.

    Plugin page: http://lesterchan.net/wordpress/readme/wp-pagenavi.html

    Could you help me, please?


Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

%d bloggers like this: