Site logo

Archived topic

Hiding featured images from single post display in custom post type

17 replies · Started by Scott Pruett on March 27, 2017

Viewing posts 1–15 of 18

I have a custom post type (created using the Custom Post Type UI plugin), and I'd like to hide the featured image from on the single post display, but retain the featured image for use on an index of posts (using WP Show Posts). Is this do-able?

Thanks!
Scott

For clarification, this is only for the CPT. I need to have featured images display for blog posts.

Hi Scott,

Are you able to provide a link to the page where you would like to hide the featured image?

Thanks!

Hey Leo, here's one example.

The image displays twice because the post is created through a form (via FormidableForms) in which an image is uploaded, displayed in a template, and also set as the featured image. The featured image will be used in an index page with WP Show Posts.

I just need to hide the featured image, i.e. the larger one above the page content.

Thanks,
Scott

Try Customizer > Layout > Page Header > Single Post Header Location > Hide.

Let me know if this works.

Thanks Leo, that does work!

However, I'd like to keep the single post header for other posts (e.g., a blog), and just hide it for this custom post type. Is that possible?

What's the name of this custom post type?

The CPT name is "product," but I think you figured that out already. :)

The CSS did the trick. I'll just use that.

Thanks for the help!

You're welcome :)

How do we avoid having the featured image output on the page? Ditto page title and other elements. CPTs inherit the blog layout, but I want them to be similar to Pages.

Hi Greg,

Can you open a new topic for this? So we don't resurrect resolved topics for other users.

Also, your site may have completely different structure so it's best to have a specialized answer for it specifically.

Thanks. :D

Opening a new topic for hiding other features would make sense, but there are already numerous forum topics with similar sounding titles, it would really be nice to get the answers without creating more. So how, please, do we stop GP from outputting the featured image on CPT single pages?

They may be similar sounding titles but we still need to verify things (ex. site structure, custom snippets, etc ) to know if the answer we'll give will 100% work on the site of the user who asked. :)

While we can give canned answers, it's not going to be a guaranteed correct answer for your site specifically if we don't know the full details like site customization, and/or if you're pertaining to the dynamic background fetched from featured image.

That's why we go the extra effort of verifying each site for each user. :D

To add further: opening a new topic lets you use the private information text field, which can be used if we have to ask for details that users don't want to disclose on public.

To answer your question:

I'm not sure if the site in question is using the theme's default post image but if it is, here's a PHP snippet you can try:

add_filter( 'option_generate_blog_settings', 'lh_custom_search_results_page_settings' );
function lh_custom_search_results_page_settings( $options ) {
    if ( is_single() && 'your_cpt_slug_here' == get_post_type() ) {
        $options['single_post_image'] = false;
    }
  
    return $options;
}

Then the line your_cpt_slug_here with the slug of your custom post type.

Digging through the code, I found generate_blog_single_featured_image().

add_action( 'wp', function() {
	if ( is_single() && 'post' != get_post_type() ) {
		remove_action( 'generate_after_entry_header', 'generate_blog_single_featured_image' );
		remove_action( 'generate_before_content', 'generate_blog_single_featured_image' );
		remove_action( 'generate_after_header', 'generate_blog_single_featured_image' );
	}
}, 55 );
This archived topic is closed to new replies.