Remove header image in Twenty Eleven WordPress theme

Currently I am using the basic theme for WordPress, which is Twenty Eleven. It is clean and easy to maintain. I like it better without the header image. I remember last time we can remove the header image at the theme options but I could not find it anymore in the latest WordPress version. So to do it manually, we need to edit some coding.

To do that, we can do it by logging in to the WordPress admin, Appearance and Editor. Look for header.php, find and delete this code :

<?php
    // Check to see if the header image has been removed
    $header_image = get_header_image();
    if ( ! empty( $header_image ) ) :
?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
    <?php
        // The header image
        // Check if this is a post or page, if it has a thumbnail, and if it's a big one
        if ( is_singular() &&
                has_post_thumbnail( $post->ID ) &&
                ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) ) ) &&
                $image[1] >= HEADER_IMAGE_WIDTH ) :
            // Houston, we have a new header image!
            echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
        else : ?>
        <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
    <?php endif; // end check for featured image or standard header ?>
</a>
<?php endif; // end check for removed header image ?>

Remember to backup your data before you do this. Good luck!

Leave a Reply