• Hi!
    How do I remove the featured image from the post (but not from the post preview)?
    I just tried to include different CSS codes from the forum and search (to functions.php or custom CSS) but nothing worked out.
    Can you help me?

Viewing 3 replies - 1 through 3 (of 3 total)
  • It looks like the problem is that this theme doesn’t give the featured image at the top of the post a unique class or id, so singling it out with CSS would be tricky. So I suggest editing content.php and removing this code, near the top of the file:

    <?php
    if( has_post_thumbnail() )
        the_post_thumbnail( 'featured-img', array( 'class' => 'image-full aligncenter' ) );
    ?>

    Now, this would be overwritten if the theme were to release an update, so you could either 1) never update the theme, or 2) create a child theme with this code removed from content.php.

    I typically just go with #1, since I edit themes so much that I “make them my own.”

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    User’s should always keep your theme up to date and creating a child theme isn’t hard.

    How do I remove the featured image from the post (but not from the post preview)?
    I just tried to include different CSS codes from the forum and search (to functions.php or custom CSS) but nothing worked out.

    I think I get it so try this, make a child theme of that Destin Basic theme.

    https://codex.www.ads-software.com/Child_Themes

    Create a new directory named wp-content/themes/destin-basic-child and in that directory put these two files style.css and functions.php.

    In style.css put these lines.

    /*
    Theme Name: Destin Basic Child Theme
    Description: Child theme for Destin Basic theme
    Version: 0.1
    Template: destin-basic
    */

    In functions.php put these lines.

    <?php
    
    // Queue up the parent theme's stylesheet
    add_action( 'wp_enqueue_scripts', 'mh_child_style' , 5 );
    function mh_child_style() {
            wp_enqueue_style( 'destin-basic-parent-style', get_template_directory_uri() . '/style.css' );
    }
    
    // Replace the featured image in posts only with a HTML comment
    add_filter( 'post_thumbnail_html', 'mh_post_image_html', 10, 3 );
    function mh_post_image_html( $html, $post_id, $post_image_id ) {
            if( is_single() ) {
                    $html = '<!-- The featured image would be here if I chose to display it. ;) -->';
            }
            return $html;
    }

    What this does is replaces the featured image with an HTML comment. No image. But it only does it for posts and nothing else.

    You’ll still have a featured image for the post. It just will not be displayed when you view the post.

    If you want to remove the featured image from the top of the single post, you can use this CSS:

    .single article .wp-post-image {
    display: none;
    }

    You can create a child theme to add this or just use Jetpack’s CSS editor to save you the hassle.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Remove featured image from post’ is closed to new replies.