admin管理员组文章数量:1289586
i simply dont want to show posts on category page and show the description only, i tried this code but it wont work if i use the zero value, 1+ value would work but not 0
add_filter('pre_get_posts', 'posts_in_category');
function posts_in_category($query){
if ($query->is_category) {
if (is_category('')) {
$query->set('posts_per_archive_page', 0);
}
}
}
i simply dont want to show posts on category page and show the description only, i tried this code but it wont work if i use the zero value, 1+ value would work but not 0
add_filter('pre_get_posts', 'posts_in_category');
function posts_in_category($query){
if ($query->is_category) {
if (is_category('')) {
$query->set('posts_per_archive_page', 0);
}
}
}
Share
Improve this question
asked Aug 8, 2021 at 19:30
RJMRJM
11 bronze badge
1 Answer
Reset to default 0Can you change is_category('')
to is_category()
? Alternatively you can use is_category('category-slug')
to hide posts in a single category.
本文标签: functionsHow to Not Show posts on Category page
版权声明:本文标题:functions - How to Not Show posts on Category page? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741397294a2376455.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论