[Resolved] Remove featured image on custom post type

Home Forums Support [Resolved] Remove featured image on custom post type

Home Forums Support Remove featured image on custom post type

Viewing 15 posts - 16 through 30 (of 31 total)
  • Author
    Posts
  • #382484
    Vee

    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.

    #382601
    Tom
    Lead Developer
    Lead Developer

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

    #435142
    Robert

    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?

    #435293
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Do you have the Blog add-on activated?

    Let me know πŸ™‚

    #436276
    Robert

    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 );
    }
    
    #436354
    Robert

    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?

    #436516
    Tom
    Lead Developer
    Lead Developer

    That’s the perfect way to do it. Very nice! πŸ™‚

    #437059
    Robert

    Thanks Tom! πŸ™‚

    #480886
    Dan

    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.

    #480925
    Tom
    Lead Developer
    Lead Developer

    That’s definitely the best option πŸ™‚

    #945790
    Thierry

    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 ?

    #946221
    Tom
    Lead Developer
    Lead Developer

    Hi there,

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

    #946272
    Thierry

    Hi Tom,

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

    #946566
    Leo
    Staff
    Customer Support

    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 πŸ™‚

    #947734
    Thierry

    Tht’as work ! thanks leo πŸ™‚

Viewing 15 posts - 16 through 30 (of 31 total)
  • You must be logged in to reply to this topic.