How to hide classes on some pages in WordPress?

How do I hide some CSS classes on some pages in WordPress? Like if I want to hide featured image in blog posts we use:

.single .post-thumbnail {
    display:none;
}

I want the class (like .single) for homepage, search page, archives, etc.

Related posts

Leave a Reply

1 comment

  1. You would need to target the page class. If you look at the source code on whatever page you are on, you’ll notice the body class include a unique identifier for your page. You can then target that way. See the Codex for a full run-down of page classes.

    Home is home, search is search, archives is archive. The homepage won’t be single because that’s reserved for posts.

    You could set custom ones with a filter.

    add_filter( 'body_class', 'new_body_class' );
    function new_body_class( $classes ) {
    
        if ( is_front_page())
            $classes[] = 'custom-class';
            return $classes;