I recently worked on a project where the client wanted to add paging functionality to each of the custom post types I had created for the site build.
To accomplish this, I downloaded and installed the WP PageNavi plugin but quickly realized that I couldn’t just simply add the
wp_pagenavi(); function and leave it at that.
After perusing the formus, I found a solution that worked for me on both custom post type archive pages using the WordPress Loop as well as WordPress templates using a custom WP Query.
If you are looking for how to add WP PageNavi to any post type archive page already using the WordPress Loop, you simply need to add the
wp_pagenavi(); function immediately after the while closing curly brace and you should be good to go!
Things get a little trickier for page templates but nothing we can’t handle!
Basically you simply need to add the paged functionality into the
new WP_Query. For the
wp_pagenavi(); function call, you also need to add a parameter for your custom query. Take a look at the code below to view how this should be setup.
I hope you found this as useful as I did! Let me know if this helped you out or if you need some help getting it set up properly. Thanks!