From the description of the plugin "Hide Featured Image":
There are instances when one wants to show featured image on single post and hide it on another post. This plugin will allow you to show or hide featured image from single post page.
Indeed there are such instances, including with custom post types, but unfortunately the solution from the plugin, shown below, is a css solution that just hides the featured image instead of programmatically "dequeuing" or disabling it:
function sh_featured_image() {
if( is_single() || is_page() ){
$hide = false;
$sh_hide_all = get_option('sh_hide_all_image');/* Hide all post or image */
$hide_image = get_post_meta( get_the_ID(), '_hide_featured', true );/* Hide single post */
$hide = ( is_page() && isset( $sh_hide_all['page_image'] ) && $sh_hide_all['page_image'] && $hide_image != 2 ) ? true : $hide ;
$hide = ( is_singular( 'post' ) && isset( $sh_hide_all['post_image'] ) && $sh_hide_all['post_image'] && $hide_image != 2 ) ? true : $hide ;
$hide = ( isset( $hide_image ) && $hide_image && $hide_image != 2 )? true : $hide;/* Hide single post */
if( $hide ){ ?>
<style>
.has-post-thumbnail img.wp-post-image,
.attachment-twentyseventeen-featured-image.wp-post-image { display: none !important; }
</style><?php
}
}
}
Obviously, the css selector .attachment-twentyseventeen-featured-image.wp-post-image
only pertains to the Twenty Seventeen theme, whereas the css selector .has-post-thumbnail img.wp-post-image
is more generic.
In my concrete use case, the featured image should not be shown on individual custom post type pages, but it should be shown on category pages listing all the items of the custom post type.
Is it possible to programmatically disable or "dequeue" the featured image on certain pages/posts rather than simply hiding it with css without editing any of the theme templates (or creating a new one)?