I did write this down, but I buried it in another blog post.
Sometimes you don’t want to display the featured image but you don’t want to remove the option from your theme.
This snippet in a plugin or child theme’s functions.php file will accomplish that.
add_filter( 'post_thumbnail_html', 'mh_post_image_html', 10, 3 ); function mh_post_image_html( $html, $post_id, $post_image_id ) { if( is_single() ) { $html = '<!-- The featured image would be here if I chose to display it. ;) -->'; } return $html; }
It doesn’t disable support for post thumbnails but replaces the code with an HTML comment if the post is_single() using the post_thumbnail_html filter. You can use other conditionals as well and even edit the HTML before returning it.
Andrea_R says:
For some themes, the featured image is pulled via the attachment status. So making sure the image is uploaded separately to the media library, instead of within the post directly, will cause the thumbnail not to show.
June 17, 2015 — 4:08 pm
Jan Dembowski says:
Attachment status. I’ve got to play with that! 😀
June 17, 2015 — 4:09 pm