admin管理员组文章数量:1292146
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. :)
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. :)
Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Jul 15, 2011 at 16:37 MTTMTT 3,58612 gold badges47 silver badges74 bronze badges 2- 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 Commented Jul 15, 2011 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. – MTT Commented Jul 15, 2011 at 20:04
4 Answers
Reset to default 1Got it figured out...
While I did manually remove the next page links, CloudFlare's cache was not playing nice.
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;
}
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.
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;
});
本文标签: How to disable pagination (nextprevious links) on post type archive
版权声明:本文标题:How to disable pagination (nextprevious links) on post type archive? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741546321a2384615.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论