Site logo

Archived topic

Remove category from blog page

7 replies · Started by Nimie on May 11, 2020

Viewing posts 1–8 of 8

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

I tried it and checked the category id. Still not working. Could there be a conflict?

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.

This archived topic is closed to new replies.