Search engine optimization of page navigation. How to do numerical pagination in WordPress without Php plugins how to do pagination

In this article, I want to show you how to add number pagination in WordPress to your blog without any plugins. The numerical pagination that I am going to implement is used on this site (if you go to the blog section and scroll to the very bottom, you will understand what I am talking about; translator’s note - approximately the same implementation is used on this blog, only through plugin). I wrote this post because I believe people usually have a hard time adding pagination to an existing site. I regularly come across threads on the WordPress.org forums where users ask similar questions: “How do I add pagination to my blog page?”, “How do I add those numbers at the very bottom of the page so users can navigate through posts?” or “How can I split my blog into multiple pages?” It seems that most users choose numerical pagination in WordPress instead of navigating using the standard “Previous Page” and “Next Page” links, which in reality does not indicate where exactly the user is at the moment.

Basic pagination using two links “Next Page” and “Previous Page” is quite simple to implement, as is well written in the code, but this navigation is not the most convenient. Imagine that a user came to your site, got to page 8 with the desired entry and left. Then he went back and decided to get the same post on page 8 - for this he would have to scroll through a bunch of pages. Imagine how annoying this is. This indicates poor usability, and it is advisable to avoid this approach if you do not want users to come back to you.

Basic setup: custom WP_Query

The first—and most important—step of creating pagination is to set up WP_Query correctly. You need to make sure that the query returns the record data. Here's a basic example of a query running:



Have questions?

Report a typo

Text that will be sent to our editors: