Archived topic
Hide featured image in single CPT
7 replies · Started by Igor on December 12, 2017
I want to hide featured image just for a CPT. I want to still show featured images in blog single posts or other CPTs, but there is no way to hide it using code. I know I could use CSS but I don’t want the code being loaded.
I've tried this but doesn't work:
add_action( 'wp', 'tu_remove_featured_images', 15 );
function tu_remove_featured_images() {
if ( is_singular( 'proyecto' ) ){
remove_action( 'generate_after_header','generate_page_header', 10 );
}
}
I'm using last version or GP and GP Premium. This worked some weeks ago. Not sure before which upgrade.
Thanks
Hi there,
Can you try:
add_action( 'wp', 'lh_remove_single_cpt_page_header' );
function lh_remove_single_cpt_page_header() {
if ( 'proyecto' == get_post_type() ) {
remove_action( 'generate_after_header','generate_page_header' );
}
}
I tried before, including other combinations. It doesn't work. There was a mistake in your code, anyway, the function name should be tu_remove_single_cpt_page_header instead of lh_remove_single_cpt_page_header. I'm placing it in my child theme's functions.php code. Any solution? :-(
Hi there,
Try this:
add_filter( 'option_generate_blog_settings', 'tu_hide_featured_image_cpt' );
function tu_hide_featured_image_cpt( $options ) {
if ( 'proyecto' == get_post_type() ) {
$options['single_post_image'] = false;
}
return $options;
}
Now it works! thanks. The question is: Is this an isolated situation? I mean, the first solution explained does usually work? I ask because I have other websites using GP and maybe I can find same situation after upgrading GP.
The first solution is for the Page Header, which was separated completely from static featured images in GPP 1.5.
A "Page Header" now requires the use of the content field in the Page Header.
Maybe would be nice idea if this is explained in Docs! ;) Thanks!!
Good idea! :)