- This topic has 17 replies, 2 voices, and was last updated 2 years, 3 months ago by Elvin.
-
AuthorPosts
-
March 27, 2017 at 11:23 am #298064Scott Pruett
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!
ScottMarch 27, 2017 at 12:06 pm #298070Scott PruettFor clarification, this is only for the CPT. I need to have featured images display for blog posts.
March 27, 2017 at 2:13 pm #298121LeoStaffCustomer SupportHi Scott,
Are you able to provide a link to the page where you would like to hide the featured image?
Thanks!
March 27, 2017 at 2:54 pm #298135Scott PruettHey 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,
ScottMarch 27, 2017 at 3:20 pm #298141LeoStaffCustomer SupportTry Customizer > Layout > Page Header > Single Post Header Location > Hide.
Let me know if this works.
March 27, 2017 at 3:23 pm #298144Scott PruettThanks 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?
March 27, 2017 at 3:25 pm #298148LeoStaffCustomer SupportWhat’s the name of this custom post type?
March 27, 2017 at 3:29 pm #298153LeoStaffCustomer Supportmaybe try this CSS instead:
.product-template-default.single .page-header-image-single { display: none; }
Adding CSS: https://docs.generatepress.com/article/adding-css/
Let me know.
March 27, 2017 at 3:39 pm #298159Scott PruettThe 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!
March 27, 2017 at 3:43 pm #298160LeoStaffCustomer SupportYou’re welcome π
December 8, 2021 at 9:58 pm #2043166GregHow 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.
December 8, 2021 at 10:01 pm #2043167ElvinStaffCustomer SupportHi 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. π
December 8, 2021 at 10:22 pm #2043179GregOpening 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?
December 8, 2021 at 10:46 pm #2043193ElvinStaffCustomer SupportThey 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. π
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.December 8, 2021 at 11:24 pm #2043213GregDigging 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 );
-
AuthorPosts
- The topic ‘Hiding featured images from single post display in custom post type’ is closed to new replies.