How to add a Pretty Pagination to your WordPress posts

Here’s a little bite that will add a nice looking numbered pagination to your blog feed. You can navigate by clicking, “Next” or the numerical page numbers. First you need to decide how many posts to show on your blog page, category page or archive page. You can adjust the number through the backend under, “settings > reading” then input the number of post you want to show. The pagination will only show if you have more posts to show than you just specified. So how do we do this?

First we need to put the function that makes it work in our theme’s function.php file.

Then we we can use our function. You could simply copy the function and enter it into your template, but I like to surround it in another div for some reason and control it that way, but you don’t have to. So, copy the function and put it in your, index.php, your category.php and your archive.php if it exists. This can go anywhere. It doesn’t have to be in the loop, so put it in your sidebar if you want.

“Oh, wait! I need it on a Custom Template Page” You can alter your query to be paged and here is how to do that.

Now that you have the function working, all that’s left to do is make it pretty by adding some styling. Start by putting this into your theme’s style.css file and change to your hearts desire.

Leave a Reply

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

+ 17 = 21