Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

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

share|improve this question
1  
What should happen if there are more than 10 (or whatever "posts per page" setting you are using) posts of that CPT? Does the archive page show all, or would you want the number of posts constrained? Also, are you using archive.php for your CPTs, or do you have specific archive-cptname.php templates set up? –  chrishajer Jul 15 '11 at 17:56
    
I still want the archive page to show, just remove the next/previous links. If the post type has more than 10 posts, do nothing. If it has less than 10, do nothing. Either way display the content of the archive-posttype template. I'm actually using the twentyeleven style setup where it the content-posttype.php template is called by archive.php. –  mattrepublic Jul 15 '11 at 20:04
add comment

3 Answers

up vote 1 down vote accepted

Got it figured out...

While I did manually remove the next page links, CloudFlare's cache was not playing nice.

share|improve this answer
add comment

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;
}
share|improve this answer
    
While that does remove the link visually, it doesn't remove it from the code... <nav id="postfooternav"><p><a href="http://url.com/archive/page/2" >Next Page &raquo;</a></p></nav> –  mattrepublic Jul 15 '11 at 17:27
    
I agree - I thought you were mostly concerned with the visual aspect. –  GavinR Jul 18 '11 at 16:19
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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