Only shows a few numbers around the first page. After a few years, a blog may have 100s of pages to scroll through, so no reason to show 100s of links to those pages. Instead, we’ll show the page we’re on, two pages surrounding it in either direction, and then links to the first and last pages.

Has Previous and Next links so that users can just click back to the page before the one they’ve been reading, which keeps it as simple as possible for those who are just reading way back whens.

Basically what we do with the code below is check how many pages we have, and if it’s more than 5, we start showing the various first, last and next/previous links mentioned and shown above. If there are less than 5, we simply show those 2-4 links. You can change the $range value in the first line to whatever you’d like to increase the number of links that are shown adjacent to the current page. So set it to $range = 3 and you’ll get three newer pages to the right and 3 older pages to the left of our current page’s marker in the pagination display.

Hi, I was really excited when I saw the comment that says this pagination will work for custom post types. I am a fairly advanced WordPress back-end developer but sadly this did not work for me with my custom post types. Admittedly, I haven’t spent much time with the configurations, I was looking for something that worked out of the box. I’ve applied to code to my functions file properly, and then added the call to my custom post type call (which is basically just a custom wordpress query for that post type). Is there something I am missing here? Do you have the post type defined (I’m not seeing it). I would love to use this code and it would be very helpful to me. It would be great if it does work for custom post types and if you would kindly help me out.

LiLShell, I use this on sites with custom post types often. When you’re talking about a “custom post type call” and “custom wordpress query” do you mean a typical WP_Query modified to use your post type? If you’re making database calls outside of WP_Query, that may be your issue.

Kind of hard for me to make any further suggestions without seeing your code.