Archived topic
Remove category from blog page
7 replies · Started by Nimie on May 11, 2020
I would like to keep one category from displaying on the blog page. I tried this:
.category-uncategorized .entry-meta {
display:none;
}
and this
function exclude_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '-1' );
}
}
add_action( 'pre_get_posts', 'exclude_category' );
Hi there,
Just to make sure, you are trying to remove a certain category from the posts loop?
If so this is the code you'd need:
https://docs.generatepress.com/article/exclude-categories-from-posts-page/
Can you make sure that the category ID is correct?
I tried it and checked the category id. Still not working. Could there be a conflict?
How are you adding that code?
One of these methods?
Adding PHP: https://docs.generatepress.com/article/adding-php/
To the child theme functions php
I just tested the code in Code Snippets and it worked for me.
Can you give that a shot first?
Not working. I have used it on other sites with no problem. All cache is deactivated.
I have used it on other sites with no problem.
Then it must be something specific to this site.
Do you another function that might be conflicting?
You might have to spend a little more time trying to debug this as we know that the code works.