Back to Community

Can't Find next_posts_link()? A Guide to Locating Your Theme's Pagination Code

25 threads Sep 9, 2025 PluginWp-pagenavi

Content

If you're trying to install the WP-PageNavi plugin, you've likely run into a common and frustrating roadblock: the installation instructions tell you to find and replace calls to next_posts_link() and previous_posts_link(), but you can't find them anywhere in your theme's files. This is a widespread issue, as evidenced by numerous support threads from users of themes like The Box, Twenty Fifteen, Hestia Pro, Cherry, and many others.

Why This Happens

The challenge arises because theme developers use many different methods to handle post navigation. While older or simpler themes might use the standard next_posts_link() and previous_posts_link() functions directly in template files, modern and complex themes often abstract this functionality. They might use custom functions, WordPress core functions like the_posts_navigation(), or integrate pagination within their own framework, making the standard code impossible to find with a simple search.

How to Find and Replace Your Theme's Pagination

Here are the most common places to look and methods to use, compiled from community solutions.

1. Search the Standard Template Files

Start by thoroughly searching these common theme template files for any pagination-related code:

  • index.php
  • archive.php
  • category.php
  • page.php
  • single.php
  • functions.php

Use your code editor's search function to look for terms like: next_posts_link, previous_posts_link, paginate, navigation, nav, the_posts_navigation, and the_posts_pagination.

2. Follow the Clues in Template Parts

Many themes use the get_template_part() function to load content. If you see a line like get_template_part( 'content', 'loop' );, you need to look for corresponding files like content-loop.php or loop.php. The pagination code is often located in these included files.

3. Look for Custom Navigation Functions

Modern themes, including default WordPress themes like Twenty Eleven through Twenty Fifteen, rarely use the simple link functions. Instead, they create their own navigation functions.

  • Example from Twenty Eleven: The pagination is inside a function called twentyeleven_content_nav() located in the functions.php file.
  • Example from Twenty Fifteen: You would need to find and replace the the_posts_pagination() function.
  • Example from Underscores (_s): The starter theme uses the_posts_navigation();

If you find a custom function (e.g., mh_postnav(), my_theme_pagination()), you will need to locate its definition, usually in the theme's functions.php file or an includes directory, and replace the relevant output code with <?php wp_pagenavi(); ?>.

4. What to Do If There Is No Pagination Code

Some themes may not have native pagination for posts where you expect it. In this case, you can manually add the WP-PageNavi function to the appropriate template file.

Where to add it: The code <?php wp_pagenavi(); ?> should be placed in your theme's template files (e.g., index.php, archive.php) after the main WordPress loop (the code that starts with while ( have_posts() )).

Important Considerations and Best Practices

  • Use a Child Theme: Before modifying any theme files, always create a child theme. This ensures your changes are not overwritten when the parent theme is updated.
  • Contact Your Theme Author: If you are using a commercial or highly customized theme (e.g., MH Magazine, Jannah, Hestia), your best resource is the theme's official support. The theme author knows exactly how their pagination is implemented and can provide specific instructions. As one community member noted, "I would contact your theme author to see if he can help. You probably will not get any help here since there are so many themes out there and it is coded differently."
  • Genesis Framework: For themes built on the Genesis framework, the pagination code is typically handled by the framework itself and may require a specific Genesis hook or function replacement.

Final Checklist

  1. Search all template files for pagination-related terms.
  2. Check the functions.php file for custom navigation functions.
  3. If no code is found, manually add <?php wp_pagenavi(); ?> to your template file after the loop.
  4. If you are unsure, reach out to your theme's support team for guidance.

By following this guide, you should be able to track down your theme's unique pagination implementation and successfully integrate the WP-PageNavi plugin for improved navigation on your site.

Related Support Threads Support