How to add Pagination to WordPress Theme

This tutorial goes over how to change posts navigation to page numbers or pagination.

The first thing you want to do is determine which WordPress file your theme is using to display your posts. In my case, it is the index.php file. In this file I found the function the_posts_navigation() and changed it to the_posts_pagination(). That will change the “Older and Newer” posts navigation to page numbers.

Other than that it is just styling and customizing the function to display the pagination like you want. Below are the SCSS styles and code I used in the video:

Mentioned in the Video Tutorial


Don’t forget to edit the other template files that might be using the_posts_navigation() if you want those to use page numbers as well. These are template files like archive.php and search.php. A good way to find these is to do a “Find” or “Search” in your text editor for the_posts_navigation() so you can find all the instances that you might want to change.