Site logo

Archived topic

Hide featured image under some conditions

9 replies · Started by webintas on December 2, 2020

Viewing posts 1–10 of 10

Hi there,

In some specific cases I want to remove the featured image. I have tried the code below but that does not work. How to do it?

add_action( 'wp','generate_remove_featured image' );
function generate_remove_featured () {
if (is_single(1256)){
remove_action('generate_before_content','generate_featured_page_header_inside_single', 10);
}
}

Hi there,

In some specific cases I want to remove the featured image.

Can you let me know what those cases are?

It depend on whether a custom field is filled out the the backend. I offer the bloggers an opportunity to insert a YouTube video instead of the featured image. If they do, I need to remove the featured image from single.

We are on the right track with the disable elements option. But is it possible to do it from the PHP code?

Wauw.. How could I miss that.

However, it did not help. I have tried to clean up and keep it simple:

add_action('wp','generate_remove_featured');
function generate_remove_featured () {
	remove_action('generate_before_content','generate_featured_page_header_inside_single', 10);
}

That does not work either.

Thanks ! That helped :-)

No problem :)

This archived topic is closed to new replies.