Troubleshooting Common WP-PageNavi Issues: Display Limits, Pagination, and Custom Queries
Content
WP-PageNavi is a powerful plugin for improving WordPress pagination, but users often encounter specific issues that prevent it from working as expected. Based on common community support threads, this guide addresses the most frequent problems and their solutions.
1. Pagination Displaying Incorrect Number of Pages
Problem: The pagination shows an incorrect number of pages (e.g., 30 pages when there are fewer, or a hard cap at 100 pages).
Why it happens: This is almost always due to a misconfigured custom query. The plugin relies on the global `$wp_query` object or a correctly passed custom query to calculate the total number of pages.
Solution: Ensure your custom query is properly set up. If you are using a custom loop, you must pass the `max_num_pages` parameter from your query object to the `wp_pagenavi()` function.
$custom_query = new WP_Query( array( 'post_type' => 'your_post_type', 'paged' => $paged ) );
// Your loop code here
if ( function_exists( 'wp_pagenavi' ) ) {
wp_pagenavi( array( 'query' => $custom_query ) );
}
wp_reset_postdata();
2. Pagination Not Working with Custom Loops (Taxonomies, foreach)
Problem: Users try to paginate a list of taxonomy terms or items in a `foreach` loop, but WP-PageNavi does not work.
Why it happens: WP-PageNavi is designed to work with WordPress's main query or `WP_Query` objects. It cannot paginate simple PHP arrays or `get_terms()` results directly because those functions do not inherently support pagination.
Solution: You must use a `WP_Query` that includes the 'paged' parameter. For taxonomies, use a tax_query instead of `get_terms()`. For a list of venues or similar items, you will need to find a way to query them as a custom post type or within the standard post structure that `WP_Query` can handle.
3. Too Many or Too Few Posts Per Page
Problem: The number of posts per page is too high or too low, affecting when the pagination appears.
Why it happens: WP-PageNavi does not control how many posts are displayed per page. This setting is determined by your WordPress reading settings or by the 'posts_per_page' parameter in your theme's query.
Solution: To change the number of posts per page, go to Dashboard > Settings > Reading and change the "Blog pages show at most" value. If this does not work, your theme is likely overriding this setting with a custom query. You will need to locate this query in your theme's files (e.g., index.php, functions.php) and modify the 'posts_per_page' argument.
4. Styling and Display Issues (e.g., "Page 1,520 of 100")
Problem: The text in the pagination is incorrect or the formatting breaks on higher page numbers.
Why it happens: This can be caused by a conflict with another plugin or theme that is modifying the main query or limiting the results. In the case of the "Page 1,520 of 100" bug, the Bing search plugin was likely returning an incorrect total result count.
Solution: First, test by switching to a default WordPress theme like Twenty Twenty-One. If the problem disappears, the issue is with your theme's code. If it persists, deactivate other plugins one by one to identify the conflicting plugin. You will need to contact the author of that plugin for a fix.
5. Disabling WP-PageNavi on Specific Pages
Problem: The pagination appears automatically on pages where it is not wanted, like the homepage.
Why it happens: The plugin's function is being called unconditionally in the theme, often in a template file like footer.php.
Solution: The best practice is to conditionally call the function. Wrap the `wp_pagenavi()` call in a conditional check to exclude specific pages. A common method is to check the page slug or ID.
if ( ! is_front_page() && ! is_page( 'your-page-slug' ) ) {
if ( function_exists( 'wp_pagenavi' ) ) {
wp_pagenavi();
}
}
By following these troubleshooting steps, you can resolve the majority of common issues with WP-PageNavi. For more complex problems, searching the WordPress support forums for your specific error is highly recommended.
Related Support Threads Support
-
Page x of x gets split if more than 10 pages displayhttps://wordpress.org/support/topic/page-x-of-x-gets-split-if-more-than-10-pages-display/
-
To much page are displayeshttps://wordpress.org/support/topic/to-much-page-are-displayes/
-
WP-pagenav in listing description taxonomies.https://wordpress.org/support/topic/wp-pagenav-in-listing-description-taxonomies-1/
-
Paginate with wp pagenavi on a Pagehttps://wordpress.org/support/topic/paginate-with-wp-pagenavi-on-a-page-1/
-
Number of pages caps at 100?https://wordpress.org/support/topic/number-of-pages-caps-at-100/
-
Add pagination to foreach loophttps://wordpress.org/support/topic/add-pagination-to-foreach-loop/
-
WP-pagenav in listing description taxonomies.https://wordpress.org/support/topic/wp-pagenav-in-listing-description-taxonomies/
-
Wp_pagenavi what page codehttps://wordpress.org/support/topic/wp_pagenavi-what-page-code/
-
Too many posts shown per page – Reduce Page lengthhttps://wordpress.org/support/topic/too-many-posts-shown-per-page-reduce-page-length/
-
Show Extra Number of Pages Navigationhttps://wordpress.org/support/topic/show-extra-number-of-pages-navigation/
-
disable wp-pagenavi on pages with template using the loophttps://wordpress.org/support/topic/disable-wp-pagenavi-on-pages-with-template/
-
Add pagination to search.phphttps://wordpress.org/support/topic/add-pagination-to-search-php/
-
show more results per pagehttps://wordpress.org/support/topic/show-more-results-per-page/
-
max_num_pageshttps://wordpress.org/support/topic/max_num_pages/
-
Options > Number Of Pages To Show — no 'auto' option?https://wordpress.org/support/topic/options-number-of-pages-to-show-no-auto-option/
-
How to show total # of pages in Navigationhttps://wordpress.org/support/topic/how-to-show-total-of-pages-in-navigation/
-
stop loading pagination beyond a certain numberhttps://wordpress.org/support/topic/stop-loading-pagination-beyond-a-certain-number/
-
WP-PageNavi in On demand themehttps://wordpress.org/support/topic/wp-pagenavi-in-on-demand-theme/