So, you are trying to make your WordPress theme, WP-PageNavi plugin compatible? While doing so, you were not able to do the same and was seeking for help and accidentally landed in this very page while searching for this. Well, you are in totally luck on this one. Here, we will describe about how to make your WordPress theme WP-PageNavi plugin compatible.
What really is WP-PageNavi plugin?
Well, WP-PageNavi is simply a WordPress plugin, which helps you to display the pagination of the posts in the archive as well as the blog pages of your site, via numeric representation, while the certain threshold to display the posts in the single page exceeds the limitation. You can read here about how to set number of post to display in blog as well as archive pages.
For eg: if you have setup your blog pages to show at most 10 posts and then you have about 11 posts in your site, then, while using this plugin in your site, it will help you to add numeric value for the pagination, instead of the theme default, Older Posts and Newer Posts button.
What is benefit of WP-PageNavi plugin?
So, what really is the benefit of using this plugin? Well, for the answer to this, let us say that the theme only displays Older Posts and Newer Posts. Now, from only this display, user will not have any idea how much pages resides in your site at all. Since this plugin, WP-PageNavi helps you to display the pagination via the numeric value, hence, the users to your site will get the idea about how much pages is available in that certain archive or blog pages they are visiting in your site.
How to make your WordPress theme WP-PageNavi plugin compatible?
Well, after the small introduction about this plugin, now its our time to make the built WordPress theme WP-PageNavi plugin compatible. So, now lets move ahead and continue our work for this.
First of all, what you have to do is, you have to open up the index.php file of your theme. Also, if you are using different file for displaying the archive pages for your site, for eg: archive.php then, open up this file too. So, after opening those mentioned required files of your WordPress theme, now just paste the below PHP code in the required place of the theme to display the numeric pagination of your site to the visitors, ie, after the WordPress post loop completion:
if (function_exists('wp_pagenavi')) :
Here, in the above code, you have to check the function exist or not, since if the plugin is not added and activated in your site, then, it is likely to occur issue in your site if that function is not checked before rendering, because this function will not exists at all if the plugin is not activated.
The settings available on this plugin is as below screenshot:
Now, after managing the above settings for this plugin in your site and adding that above mentioned code in your theme file as mentioned, then, you should be able to see the outcome of this as the screenshot below:
Here, above you can now clearly see that the pagination of the archive as well as the blog pages is rendered via the numeric value. Also, you could see that the total number of pages to your site is also represented via Page 1 of 5 in our case, this might be other in your case.
So, if you have followed the above instructions properly and was successful on integrating the WP-PageNavi plugin into your theme, then, we can now assume that you now can easily make any of the WordPress theme WP-PageNavi plugin compatible more easily. But, if you are still confused and want more help on this, then, drop the comment below in the comment box and we will follow it up.