Skip to content

Selah.

Pause, and calmly think on that.

Menu
  • About
  • Chords
  • Free Gift
  • Highlights
  • Links
  • Microposts
  • The New Covenant
  • The Small Web
Menu

How to fix WordPress Twenty Eleven Featured Image

Posted on March 21, 2015 by Shovas

I like the Twenty Eleven theme and I still haven’t upgraded it. Luckily, some people are keeping it up to date and compatible with the latest WordPress in 2015! But there was one bug that bothered me for a long time and that was featured images were broken. These are the big header images at the top of posts (for example, the big image at the top of this post, or the grid of cars image at the top of one of my other posts). These image are just broken and will not display your custom featured image in the stock Twenty Eleven. So here’s how I fixed it…

diff --git a/wp-content/themes/twentyeleven/header.php b/wp-content/themes/twentyeleven/header.php
index f48e4cf..a9aca8a 100644
--- a/wp-content/themes/twentyeleven/header.php
+++ b/wp-content/themes/twentyeleven/header.php
@@ -86,8 +86,10 @@
                                                 * This result would be the suggested width if the theme were to implement flexible widths.
                                                 */
                                                $header_image_width = get_theme_support( 'custom-header', 'width' );
+                                               $header_image_height= get_theme_support( 'custom-header', 'height' );
                                        } else {
                                                $header_image_width = HEADER_IMAGE_WIDTH;
+                                               $header_image_height = HEADER_IMAGE_HEIGHT;
                                        }
                                        ?>
                        <a href="<?php echo esc_url( home_url( '/' ) ); ?>">
@@ -97,10 +99,11 @@
                                         * 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 ) :
+                                                       ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) )
+                                                       ) :
                                                // Houston, we have a new header image!
                                                echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
+                                               echo "<!-- here1 -->";
                                        else :
                                                // Compatibility with versions of WordPress prior to 3.4.
                                                if ( function_exists( 'get_custom_header' ) ) {
@@ -110,6 +113,7 @@
                                                        $header_image_width  = HEADER_IMAGE_WIDTH;
                                                        $header_image_height = HEADER_IMAGE_HEIGHT;
                                                }
+                                               echo "<!-- here2 -->";
                                                ?>
                                        <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" />
                                <?php endif; // end check for featured image or standard header ?>

The only thing I really did here was remove the && $image[1] >= $header_image_width condition which was preventing the feature image from displaying. Ignore the other diffs, I must have committed that stuff by accident while playing around. :)

Hope this helps! Good luck!

Comment Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Your post must include a link to this post.

How does this work?
Write a response on your own website and include a link to this post. Then submit your response’s URL here. Your response may appear here after moderation. To update or remove it, edit or delete your original post and submit the same URL again. Learn more about Webmentions.

Loading ...

No more microposts.

  • The Day Grok Schooled All Comers And Argued For Christ As God
  • “Not a Genocide”
  • Not a Genocide, Part 4: Conclusions
  • Not A Genocide, Part 3: Memories and Testimonies
  • It’s December 1st and that means Merry Metal Christmas Music
  • Not a Genocide, Part 2: Conditions at Home
  • Not a Genocide, Part 1: Disease and Nutrition
  • YouTube Finds: The Weather Network Music 2000s
  • Smallweb Finds: Versepad.com – The text editor for poets
  • Nobel Prize Winner: “Cell biology is a hallucination.”

bible canada centos christ christian christmas church creation Creation Magazine evolution faith family game genesis God gog good google government heart iracing jesus life linux love matthew music pc poem poetry quote racing romantical salvation science sim Small Web Smallweb Finds truth update video windows word YouTube YouTube Finds

Log in
© 2026 Selah. | Powered by Superbs Personal Blog theme