I'm creating a plugin that uses a custom post type. I do not want to make a custom template for viewing the posts and discovered I can add a filter for the_content to include my custom fields, this works great. However, I don't want visitors to navigate the custom post types with the previous next navigation. It there a way to remove these without creating a custom template?

Thank you for taking the time to look at my issue.

1 Answer 1


Try this:

function remove_link( $format, $link ) {
    return false;
add_filter( 'previous_post_link', 'remove_link' );
add_filter( 'next_post_link', 'remove_link' );

It should work if the theme uses next_post_link() and previous_post_link().


  • 1
    Darko, Thank you, looks like your memory is a was a little hazy but I was able to sort it out. Here's what I wound up with and it's seams to solve my issue. (Can't figure out how to enter returns in comments, sorry for the lack of formatting...): function remove_link( $format ) { return false; } add_filter( 'previous_post_link', 'remove_link' ); add_filter( 'next_post_link', 'remove_link' );
    – Jason M
    Jan 30, 2013 at 17:44
  • Oh oh, sorry about that! Will fix it, but glad you got it working. Feb 1, 2013 at 20:54
  • How do you make this work only for certain post types?
    – Flimm
    Sep 9, 2020 at 14:18
  • I have tested this code snippet on Twenty Twenty and it doesn't remove the previous / next post links... Any idea?
    – collimarco
    Jan 5, 2021 at 20: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.