• Hi there!
    Is there a way not to have the featured image displayed on posts? I would need only the title, I’ve seen here that there is a possibility to change this via Custom CSS, but no actual indication on how to do it.
    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there,

    It is possible to hide featured images on posts (but not the home page) with the following custom CSS:

    .entry-hero .post-thumbnail {
        display: none;
    }
    
    .entry-header-wrapper {
        position: inherit;
        background-image: inherit;
        padding-bottom: initial;
    }
    
    .entry-hero .entry-meta, .entry-hero .entry-meta a, .entry-hero .entry-title {
        color: inherit;
        text-shadow: inherit;
    }

    In case you’re not aware, to add custom CSS: Firstly set up a child theme or activate a custom CSS plugin. (If you have Jetpack installed then you can activate its custom CSS module.)

    If you’d like to completely remove the underlying code that generate the featured images for individual posts (rather than using custom CSS to hide the image) then you would need to first create a child theme.

    Let me know how that goes and if you have any further questions! ??

    Thread Starter georgedamian78

    (@georgedamian78)

    Thanks!
    I tried it and it works to some extent. The problem is that the title of the post overlaps the line separating the content area from the sidebar area. In a post without a featured image the horizontal line under the main menu is conected to the line separating the content area from the sidebar area. I wish that the title in a post with a featured image to be aligned like in a post without a featured image. Any idea?

    @georgedamian78: I used the above CSS on my own set up of Canard and haven’t been able to replicate the behaviour you described. Could you please share a link to your site to help me better understand what you’re referring to? I’ll be better positioned to help out from there.

    Thread Starter georgedamian78

    (@georgedamian78)

    Hi there!
    Here is a link to a post with a featured image, using the CSS above:
    https://www.kishiniov.eu/ro/istoria-lumii-4-principii/
    Here is a link to a post without a featured image (the CSS above active):
    https://www.kishiniov.eu/ro/deci-epoca-fanariota-nu-existat-ba-da-existat-ne-o-spun-contemporanii/

    Hi @georgedamian78,

    Apologies for the delay in my response! The Automattic team are currently at our annual company retread, so it may take us a little bit longer to reply to questions over the next week.

    Canard adds some underlying code to control the layout on posts with featured images using JavaScript. It’s this code that’s causing the issue with the sidebar.

    In order to prevent the JavaScript from loading, you would need to create a child theme and add the following to the functions.php file:

    function canard_child_dequeue_scripts() {
        wp_dequeue_script( 'single-thumbnail' );
            wp_deregister_script( 'single-thumbnail' );
    }
    add_action( 'wp_print_scripts', 'canard_child_dequeue_scripts' );

    From there, copy/paste Canard’s content-single.php file to your child theme’s directory. Find and remove the following code from that file in order to stop featured images from being displayed on single posts:

    <?php if ( has_post_thumbnail() && ( ! has_post_format() || has_post_format( 'image' ) || has_post_format( 'gallery' ) ) ) : ?>
    	<div class="post-thumbnail">
    		<?php the_post_thumbnail( 'canard-single-thumbnail' ); ?>
    	</div>
    <?php endif; ?>

    Let me know how that goes or if any extra questions come up.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Featured image on post’ is closed to new replies.