The code in the answer of this thread works fine, but one part I don't understand:

Remove wp_link_pages() from the template

Where is the exact code to remove? I looked into /wp-includes/post-template.php, but removing it there produces an error. At the moment, with using the code:

add_filter( 'the_content', function( $content ) { return $content . wp_link_pages( array( 'echo' => FALSE ) ); }, -1 ); // Lower number = higher priority.

the pagination appears twice: One above and one below related posts. So I'll have to delete the second one, right? How does it work?

  • Maybe this approach can help, where you don't have to remove it from your template file.
    – birgire
    Feb 19, 2017 at 13:49

1 Answer 1


No you don't remove it from /wp-includes/post-template.php. This is a WordPress core file and you should never edit any WordPress core file.

The answer is talking about removing the call of wp_link_pages function within a template file.

Which template file to edit depends on the theme and the URL you are visiting. Typically it should be /wp-content/themes/<your-active-theme>/single.php.

But templates can be divided in multiple files and call to wp_link_pages function may be in any of those template part files.

For example, in twentyseventeen theme, it can be found on multiple files. For pages, it's in:


For posts, it's in:


If you still cannot find which template file to edit for your currently active theme, you may read this guide to find out.

Read more about WordPress theme template files for posts and pages.

Also, while you remove the wp_link_pages function call from any template file, make sure you have basic understanding of PHP function calls. Since the function call may involve multiple lines.

Update: How to remove wp_link_pages pagination from a Genesis Theme:

(Since it's mentioned in the comment that it's the Genesis LifeStyle Pro Theme)

Themes with Genesis framework handle pagination differently. With a Genesis Theme, you'll not actually find an explicit call to the wp_link_pages pagination function in the template files, as it's handled by the Genesis framework.

So in that case, remove the the CODE you used in the question, and instead, use the following CODE:

add_filter( 'the_content', function( $content ) {
    remove_action( 'genesis_entry_content', 'genesis_do_post_content_nav', 12 );
    return $content . wp_link_pages( array( 'echo' => FALSE ) );
}, -1 );

Now you'll not have the default pagination provided by your Genesis theme.

  • thank you for your detailled answer. I installed "What the file" and found 'single.php' as template. But there is no wp_link_pages inside. In all other templates of my "LifeStyle Pro" - Genesis-theme I couldn't find the item. Are you familiar with Genesis? Or anybody else? Feb 19, 2017 at 11:20
  • Yes I shoud've, sorry. Where have I to add this line? In my custom-template-files? I have 5 custom-category-templates for my posts. Feb 19, 2017 at 12:13
  • It is still doubled. I created the single.php in lifestyle pro and purged / flushed all caches on each level. But no effect so far. Feb 19, 2017 at 20:11
  • @RainerBrumshagen I was able to reproduce your problem and found a better solution. Please use the new CODE in the Update section of the answer.
    – Fayaz
    Feb 20, 2017 at 9:41
  • Yessss! Perfect! Exactly how I want to have this. Thank you very much! Feb 20, 2017 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.