Show Excerpts and Post Thumbnail Twenty Eleven Theme

Adding post thumbnails and excerpts to Twenty Eleven theme is not much different than how they would be added to Twenty Ten.

The first step is to create a functions.php file for your child theme if you don’t already have one and add this to it. This adds our own custom size thumbnail of 140px X 140px.

I strongly recommend installing and running Ajax Rebuild Thumbnails plugin after completing this tutorial. It will create a new image size for each featured image. You can uninstall it after it’s finished.

// This sets the dimensions for the thumbnails displayed on the homepage
	add_image_size('excerpt-thumbnail', 140, 140, true);

The next step we need to tell our theme to display excerpts instead of the full post. Copy content.php to your child theme directory and open it. Find this block of code around line 35

		<?php if ( is_search() ) : // Only display Excerpts for Search ?>
		<div class="entry-summary">
			<?php the_excerpt(); ?>

Change it to this.

		<?php if ( is_search() | is_home() ) : // Edit this to show excerpts in other areas of the theme?>
		<div class="entry-summary">
		<!-- This adds the post thumbnail/featured image -->
			<div class="excerpt-thumb"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
		<?php the_post_thumbnail('excerpt-thumbnail', 'class=alignleft'); ?></a></div>
			<?php the_excerpt(); ?>

By adding | is_home() to the if statement it tells our theme to display excerpts on the homepage. I find doing it this way allows more control over which areas display excerpts and which display the full post.

Just below that you can see we’ve added the post thumbnail, the size of this is controlled by what we added to functions.php in the first step.

Now just save those two files and add a featured image to your posts and you’ll see post thumbnails with excerpts.

79 thoughts on “Show Excerpts and Post Thumbnail Twenty Eleven Theme

  1. Daniel


    Very helpful post. I’ve added the code in each of the php files, however the featured image is not resized to 140×140. Can you please help? Also, when I try to update the functions.php (from the child theme) I get the following warning:

    /* This sets the dimensions for the thumbnails displayed on the homepage */ add_image_size(‘excerpt-thumbnail’, 140, 140, true);
    Warning: Cannot modify header information – headers already sent by (output started at /hermes/bosweb/web061/b615/ipg.augmentedtomorrowcom/smuchi/wp-content/themes/twentyelevenchild/functions.php:3) in /hermes/bosweb/web061/b615/ipg.augmentedtomorrowcom/smuchi/wp-admin/theme-editor.php on line 103

  2. Knuth Becker

    hi zeaks,
    The code doesn’t seem to work for me. I’ve created a child theme with the style.css, fuctions.php, and content.php. The funtions.php part seems to fail for me. When I try to upload and select the child theme, it at the top says

     // This sets the dimensions for the thumbnails displayed on the homepage
        add_image_size('excerpt-thumbnail', 140, 140, true); 

    just as the functions.php part, and didn’t displayed any excerpts. I also tryed to import the functions.php code from twenty eleven and then enter the

     // This sets the dimensions for the thumbnails displayed on the homepage
        add_image_size('excerpt-thumbnail', 140, 140, true); 

    then it displayed a “Fatal error”
    don’t know what to do :(

  3. Zeaks

    Hi Brian, do you mean the size of the headers in the header area? Or the size of the featured image in the actual post? (sticky post is the same as a regular post, it’s just positioned at the top of the page)

    Your headers will always be displayed at whatever size they are set to (1000×288 is default) changing the post thumbnail size has no effect on those, it will only change the size of the image displayed in the post for that one featured image.

    1. Brian

      Fantastic, thank you sir.

      Any chance that you could shoot me an email? I am trying to embed a video into my sidebar, but I can’t figure it out for the life of me. The text widget is messing it up and I have been searching the forums, websites, etc. but keep coming up empty.


  4. Mitch

    This is great, thanks. But, how would I change the link at the end of the excerpt to be the same thing as the link? Is this possible? I have a plugin installed that slides down more content when the is clicked. It seems like the end of the excerpt is not the same as the “more” function.

  5. Stefan

    Nice work dude, that would be exactly what i am looking for so long.

    But there is one more question, for thumbnails. Would it be possible, by using the functions.php to automaticaly adding a thumbnail to any published post? For example, i published a new post and then automaticly, called by the functions.php, a thumbnail will be set for this new published post while using the first found image in the post.

    And if there wouldnt be a image in the post, it would set a defined placeholder image for the thumpnail. WOULD THAT BE POSSIBLE and if YES, HOW?

    I searched the web a lot, but until now i found nothing like your code. Maybe i does the wong searchterm… 😛

  6. Pingback: 7 New Post/Page Features You Should About « WEB WAR BEGIN

    1. Zeaks

      Hi Stefan. If you are using a child theme, add this to your functions file

      /* Removes the excerpt_more filter */
      function custom_remove_auto_excerpt_filter() {
         remove_filter( 'excerpt_more', 'twentyeleven_auto_excerpt_more' );
      add_action( 'after_setup_theme', 'custom_remove_auto_excerpt_filter' );
      /* Adds a pretty "READ MORE" link to custom post excerpts. */
      function custom_auto_excerpt_more( $more ) {
          return '… ' . custom_continue_reading_link();
      add_filter( 'excerpt_more', 'custom_auto_excerpt_more' );
      /* Returns a "READ MORE" link */
      function custom_continue_reading_link() {
          return ' <a href="'. esc_url( get_permalink() ) . '" rel="nofollow">' . __( 'Fortsetzen Lesen <span class="meta-nav">→</span>', 'twentyeleven' ) . '</a>';

      Not sure if I spelled it right, I used Google translate. If your theme doesn’t have it’s own functions.php file, create one and make sure to add the opening php tag at the top

      1. Stefan

        Thanks a lot Zeaks. 😀

        German is worst for learning, even for German native people. The speeling might be correct, but correctly it calls “weiterlesen” ! 😉

        I’ll give your additional posted Code-Snippet a try, and if i had trouble with it i will come back, to ask for some help.

        If you not seen it, i post a translated Version of your original Post for all the German Users that arent not that good in English. And i made some Links, back to you and the article. :)

  7. Pingback: Show Excerpts and Post Thumbnail Twenty Eleven Theme – Ein paar Anpassungen am Child-Theme! | BLOG

  8. Pingback: 7 New Post/Page Features You Should About | webkracken

    1. Zeaks

      Hi Olaoluwa. I don’t think it’s possible to display 2 featured images in a post. There is probably a way to display images included in the post (I don’t know how without reading up on it), but there is only meant to be one featured image.

  9. Hortensia

    And Great Learning!
    I just have one question…..
    I have included your code to show excerpts on my archive pages, bur how can I get the title to appear to the left to the image where the excerpt is located instead of having it above the image?

  10. sonal

    hi Zeak,
    i am facing the problem regarding the thumbnail on static page.
    after so many trials ,still it is not working properly.i mean only excerpt is working no thumbnail is der.
    can u pls help.

  11. thevode

    NIce!, thanks, but I have a question. I’m using the actual version of Twenty Eleven and the excertp works, and the Ajar Plugin too, but not show the thimb, where I have to paste this code?:

    // This sets the dimensions for the thumbnails displayed on the homepage
    	add_image_size('excerpt-thumbnail', 140, 140, true);
    I have pasted it just above:
    function twentyeleven_excerpt_length( $length ) {
    	return 100;
    add_filter( 'excerpt_length', 'twentyeleven_excerpt_length' );

    Into the functions.php 336 line.

    Thanks and congrats for your site!

  12. Alex

    Thank you very much for the tutorial. One question, though: the code works, but the post list now extends outside the main page background. Is there a way to break the post list? Any idea how to fix this? Thank you very much in advance.

  13. Ray

    No thumbnails have appeared beside my posts but worked great for showing only snippet of posts.. I wasn’t sure where to put this in the functions php so just put it at the bottom………I know very little about code

    // This sets the dimensions for the thumbnails displayed on the homepage
    add_image_size(‘excerpt-thumbnail’, 140, 140, true);

    I just pasted this at the bottom of all the other code

    Also would like to get rid of that little comment on this post bubble.

    thanks…great info

    P.S. I also installed Ajax Rebuild Thumbnails plugin as you suggested.

    1. Zeaks

      Hi Ray, if you open a forum post and link the files you have edited on I’ll take a look for you. I’ve visited your website but it looks like you have an error in your functions file.

      1. Ray

        My site went down after I messaged you.

        I never heard back and went in to remove that code and must have taken something extra out.

        Can’t get back in.

        Paying Hostgator to install a backup they have, however I will most likely have to start over as most of my improvements will be lost as the backup is not so recent.

  14. Fnights

    Hi, this code seems don’t work anymore after upgrade to WP 4.2 amd twenty eleven 2.1, can you fix it pls?
    I really need it to work properly, is the best for my little blog. :)

    1. Zeaks

      Hi Fnights, I just tested this and the code still works using the newest Twenty Eleven and WordPress version. Please check your code. If you’re still having problems open a forum post and show me your content.php file and I’ll take a look.

Leave a Comment

Your email address will not be published. Required fields are marked *