How to disable pagination (next/previous links) on post type archive?

How can I remove the next and previous links in a custom post type archive page, but only for that post type?

I know I could wrap any function in if ( get_post_type($post) == 'myposttype' ) {} but I can’t find a solid snippet to remove the pagination.

Read More

I have tried a few solutions, this being one of them, but nothing is working. And yes, I did try removing them from my template. 🙂

next page link

Related posts

Leave a Reply

4 comments

  1. This will visually remove it from the page (but the links will still be in the HTML):

    Use the class on the tag to use a CSS selector to set the Next/Previoius link CSS to “display:none”

    body.post-type #nav-below {
        display:none;
    }
    
  2. Easiest way: open your archives.php template (or index.php if no archives.php) and copy it over to a new template and name it “archives-{post-type-name}.php”, then open it and remove the pagination function.

  3. You can add formatting to raw post content by applying the content filters directly to post_content ( add code to functions.php wordpress) :

            add_filter('content_pagination', function ($pages)
            {
                $pages = [join('', $pages) ];
                return $pages;
            });