Site logo

Archived topic

Hide featured image on single post page for specific category

9 replies · Started by Denise on December 9, 2017

Viewing posts 1–10 of 10

Hello GP Friends,

How can I hide the featured image on single post pages for a specific category? I'm using GP Pro and have a child theme.

Many thanks for the fabulous theme!

Denise

Hi there,

We can use some CSS for that. Can you link me to one of those single posts?

Thanks!

Thanks Leo. I have responded by email to send you the links.

Denise

Hi Leo,

I added the CSS to the child theme style sheet, but it didn't change anything. Could we do this with a function, hook or filter?

By the way, I'm a database programmer, so I'm pretty comfortable with the code side of things if we need to go there.

Denise

I think the selecter that controls this image is:
.post-image-aligned-left .inside-article .featured-image

Did you add Tom's php snippet?

You could try this:

add_filter( 'generate_single_featured_image_output', 'tu_remove_single_post_image' );
function tu_remove_single_post_image( $output ) {
    if ( in_category( 'video' ) ) {
        return '';
    }

    return $output;
}

Hi Leo and Tom,

Leo, you are correct.I forgot to add the php code snippet. Once I did, the CSS display none method worked great. Then I commented that out and tried Tom's filter, that didn't need the CSS. That also worked. I will use the filter method.

Thanks a million for your continued great work. I LOVE the GP theme. You've made this web project a joy to work on. =)

Tom's method is definitely better :)

Glad we could help!

This archived topic is closed to new replies.