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);
        }      
    }
}

1 Answer 1

0

Can you change is_category('') to is_category()? Alternatively you can use is_category('category-slug') to hide posts in a single category.

2
  • yeah but it still showing posts, i just want to show the description and completely remove all post list below it
    – RJM
    Commented Aug 13, 2021 at 15:10
  • Can you change $query->is_category to $query->is_category()?
    – DeltaG
    Commented Aug 13, 2021 at 15:16

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.