Site logo

Archived topic

Remove featured image on custom post type

30 replies · Started by SCIP on March 11, 2017

Viewing posts 16–30 of 31

I tried moving the single post header to "above content area" and other locations too just to see... no change.
and just removing the single post header ( made with BB Themer) didn't affect the feature image appearance either.
Thanks for your help with this.

I assume you changed this line to match your custom post type name? if ( is_singular( 'firma' ) )

I can confirm that this doesn't appear to be working but it may be because it looks like to removes the page header instead of the actual feature image. When I edit the single content file, removing this: do_action( 'generate_before_content'); removes the feature image as desired, however I'm not sure if that is the best way to do that. I don't want to remove something essential. Main goal here is to simply remove the feature him.

 add_action( 'wp', 'tu_remove_featured_images', 15 );
function tu_remove_featured_images() {
    if ( is_singular( 'tutorial' ) ){
        remove_action( 'generate_after_header','generate_page_header', 10 );
    }
}

I'm trying to remove the feature image from the custom post type called "tutorial".

Any ideas?

Hi there,

Do you have the Blog add-on activated?

Let me know :)

Yes I do. Just to be clear I don't want to remove the feature image for all blog posts, just the custom post type. I tried poking around the files to see what the customizer does to remove the featured image (as I see that is an option) for single posts and I was able to find a filter just not sure how to hook into this in order to try to remove the feature image:



	$image_html = apply_filters( 'generate_single_featured_image_html', $image_html );

	echo apply_filters( 'generate_single_featured_image_output', sprintf(
		'<div class="featured-image %2$s">
			%1$s
		</div>',
		$image_html,
		implode( ' ', $classes )
	), $image_html );
}

I managed to remove it like so.

function my_post_image_html( $html, $post_id, $post_image_id ) {
if(is_singular('tutorial')) {
return '';
} else

return $html;
}
add_filter( 'generate_single_featured_image_output', 'my_post_image_html', 10, 3 );

Any issues doing it this way?

That's the perfect way to do it. Very nice! :)

Thanks Tom! :)

If you never need a featured image on a custom post type, then just make sure when the CPT is defined it does not support thumbnails.

That's definitely the best option :)

Hello,

i re-open this post because i have the same problem and the snippets don't work. If it's possible i don't want use the css, have you a idea ?

Hi there,

Just to confirm, what exactly are you wanting to do?

Hi Tom,

I don't want displaying the image featured on my custom post type single page.

Give this a shot:

add_filter( 'option_generate_blog_settings', 'lh_cpt_single' );
function lh_cpt_single( $options ) {
    if ( is_singular( 'CPT NAME' ) ) {
	$options['single_post_image'] = false;
    }
    return $options;
}

Let me know :)

Tht'as work ! thanks leo :)

This archived topic is closed to new replies.