Create WordPress Pagination Without a Plugin

Pagination is a necessary feature to any WordPress blog. One of the most popular plugins used is WP-PageNavi which is an excellent plugin but WordPress already actually has a function to do this for us. This function was introduced with WordPress 2.1 and all bloggers should be using it by now. Today, I will show you how to implement a WordPress Pagination without a plugin by using the function. I will also be showing you how to do some simple styling to the pagination links. Let’s get started!

Step 1: Add the Function

First we need to open functions.php and paste the following function inside of it.

Step 2: Activating the Function Within Theme

Next we need to place the following code below the loop so the pagination will be visible. Placements of this snippet and files it needs to be added to will vary depending on template/file structure of certain themes but typically it will be added to index.php, search.php, category.php, etc.. All pages that require it.

Example of my index.php placement:

HTML Results:

Visual Results:



Step 3: Styling the Pagination

Before I went and styled this, I was working with a fixed 960px width area so the settings used in the function above needed to be modified. If you run into issues with the links dropping down a line because of insufficient space, modify $a['mid_size'] = 5; from the function to shorten the amount of links on left and right side of current page. I’ve changed to 2 in this demonstration.

I’ve commented everything so it can be easily modified to suit your needs. Again this was for demonstration purposes only so the styling is very basic, modify the classes to suit your needs.

Styled Results:


Leave a Reply

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