Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

How to Display Post Excerpts in WordPress Themes

Last updated on by
Follow WPBeginner on YouTube
How to Display Post Excerpts in WordPress Themes

Some of our users wanted us to post a tutorial on how to display Post Excerpts in WordPress Themes. This is a very simple tutorial that anyone can implement and take advantage of this built-in feature. The benefit of implementing this tutorial is that it decreases page load time and it increases the pageview count.

How does it Decrease Page Load Time?

If you write long posts like best practices of contact forms or must have iphone apps for bloggers which has a lot of images, then having them load on one page can significantly impact your page load time. By adding this technique, you can simply show a mini description of the article and let user view the post on single post page.

How does it Increase Page View count?

Sometimes users just read the post on the category page if you don’t use the excerpt. By adding it this way, they will go to the original post. That is 2 page views instead of 1. It also encourages users to make a comment on the post because comment form is also on this page and they don’t need to load a separate page to make a comment.

Tutorial

Open your index.php file, archive.php file, and category.php file. Now some of you might not have all these files in your template, so just open the ones that you do have.

Find the following code:

<?php the_content(); ?>

And replace it with:

<?php the_excerpt(); ?>

Now you can write custom excerpts for your posts from your WordPress admin panel and have it displayed in your theme.

Add Post Excerpts in WordPress

If you do not write a custom excerpt, then WordPress automatically takes the first 55 words from your post and put them in an excerpt with elipses and display it. You can change the word limit starting from WordPress 2.9. If you want to change the word limit open your functions.php file and add the following function:

// Changing excerpt length
function new_excerpt_length($length) {
return 100;
}
add_filter('excerpt_length', 'new_excerpt_length');

// Changing excerpt more
function new_excerpt_more($more) {
return '...';
}
add_filter('excerpt_more', 'new_excerpt_more');

If you want to see this code working live, just click on any of our categories from the navigation menu and you will see that we do not display full posts.


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »
  • http://www.wpbeginner.com/ WPBeginner Staff

    put it right before or line.

  • http://www.wpbeginner.com/ WPBeginner Staff

    put it right before or line.

  • Rahul

    I have used experts for some of my posts but i found a problem, special signs like,”! are not rendering properly and there’s some utf-8 problem… can you guys conform whether its a WordPress problem or my hosting. Though the problem only causes in my excerpts (summary) but the article with “are opening up fine” and can be read properly. If its a WordPress issue please let us know if there’s any solution to it.

    Thanks,
    RAHUL

  • Kouami Sessou

    I wanted to use excerpt for “summary” or short description for my posts..
    It doesn’t work, when excerpt is not available for the post.
    http://www.yeswefoot.com/

    Looking for a plugin

  • Stefan

    Many thanks for the write up!

    Helped me out a lot! :-)

  • Seth

    I am using the twentythirteen template. None of the files mentioned have “the_content” in them. Also, there is no longer a “loop.php” file. (I only want my archives – tag and category to have the excerpt).

    This is what I see in the archives.php and category.php:

    Changing ‘content’ to ‘excerpt’ also doesn’t seem to do the trick.

    • http://www.wpbeginner.com/ WPBeginner Support

      Seth Twenty Thirteen uses content templates you will find the loop in content.php.

  • Yaz

    Thanks, but how do I get it to show an image too?

    • http://www.wpbeginner.com/ WPBeginner Support

      you can use <?php the_post_thumbnail(); ?>> in your template.

  • lester

    finally . . . . FINALLY !!

    i FINALLY found an answer to a problem with wordpress.

    for the love of God and flowers and good food and wine!

    thank you !! thank you !! thank you !!

  • Daniel Z

    Thanks! This worked like a gem in the inStyle theme by Elegant Themes. I actually had to edit the code in home.php, but thanks for leading me in the right direction.

  • Trenton Miller

    This is great, it’s working for me now. I would like to have the images that I have at the beginning of blog posts that I inserted via HTML, not the Featured Image method. On the blog posts where the image is within the first 55 characters, or whatever you set it to, how can I get it to appear? Is there something extra to add into functions.php?

    • http://www.wpbeginner.com Editorial Staff

      Automatic excerpts do not show HTML elements. You have two options. Either write a custom excerpt using the excerpts field in your write panel. If you don’t see it, then look at the top right hand corner “Screen Options”. The other option is to use the_content, and utilize the more tag.

  • Dr. Erika

    This is AWESOME. Seriously thank you wpbeginner for all your articles.

    Any idea of how to add pictures to the displayed excerpts?

    • Dr. Erika

      (nevermind, I figured it out)

  • Bridget

    OMG dude, thank you so much for this! I literally spent like 45 minutes trying to figure this out with an elegant theme, only to find that your solution took about 12 seconds. Gahh! Oh well, all is well that ends well! Thanks!

  • Sudip

    The excerpt box is not appearing on my PC. Please help me.

    • Deepak

      Hye Sudip,
      Open any post to edit. On the top of it you will find the screen option. Click on that , then you will see so many options there. Then go to the excerpt option , check on that option. Then below the title and content box, you can see the excerpt box .You can write your excerpt content there.

  • Jay Madisson

    Hi,

    Im just wondering, where can I find the (Open your index.php file, archive.php file, and category.php file.)? Sorry for being a noob in HTML :(

    Cheers,

    Jay MAdisson

    • http://www.wpbeginner.com Editorial Staff

      It would be in your /wp-content/themes/themename/ folder.

      • Jay Madisson

        Hi, Im using Easel Theme, I opened index.php and archive.php but I could not find the code
        :(

    • Jerry

      I’m sorry, are we speaking here of files that reside on my computer? I thought the whole blog was done online. I have no software for WordPress on my computer. I have not downloaded anything. What am I missing? Does one have to know HTML code to blog?

  • Rich

    Hello, I’m using the 2010 theme on the blog and it didn’t change to when I replaced content with the word excerpt. Is it something I’m leaving out??

    • http://www.wpbeginner.com Editorial Staff

      Did you change the loop.php?

  • Emma

    I am using the new twenty twelve theme to base a child theme on and cannot get excerpts to work at all. I looked in all the files you suggest above, but cannot find
    in any of them. Similar to Heather I have imported my blog from blogger too…
    There also doesn’t seem to be a loop.php file
    Help!

    • http://www.wpbeginner.com Editorial Staff

      The twenty twelve theme uses content.php and various variations of those.

      • Emma

        Thanks for this – I changed entry-content in content.php to

        and it has worked!

        The problem I have now is how to get the excerpt text to wrap around the thumbnail, which I would like to float either right or left.

        Any ideas?

        Thanks

  • Erin

    Maybe you can help me here. There is no in any of the files you listed above; index.php, archive.php, or category.php. This is the closest thing that I see (from my index.php file).

    Can I change something in this code or add some new code?

    • http://www.wpbeginner.com Editorial Staff

      If none of those files exist, that means you are using a child theme. You will have to utilize the hooks in the parent theme framework. We don’t write tutorials specific for theme frameworks.

  • Chris

    I’m using the twentyeleven theme and “the_content” does not appear in any of the three files mentioned. I’m stumped.

    • http://www.wpbeginner.com Editorial Staff

      Look in the loop.php file.

  • HemantKokcha

    I am trying to get excerpt but i cant get excerpt by both of your method so tell me correctly how wll i get excerpt in traction theme.

    • wpbeginner

      @HemantKokcha There is only one method… changing the_content to the_excerpt… The other function is to controlling excerpt length and the excerpt read more. If its not showing in your theme, then perhaps try contacting the theme author. Because this is the only way of doing it.

  • wpbeginner

    @clwdk You would need to change the loop.php file for the archive.

  • clwdk

    Hi there,

    I am using the newest version of the twenty ten theme and am not sure where to change the <?php the_content(); ?> to <?php the_excerpt(); ?>. There is nothing in the index.php as far as I can see. Am I overlooking something? Thanks for any help you can give me.

    CARL

  • wpbeginner

    @Ibadullah You have to add this code in your theme’s functions.php file. It should work perfectly fine because this is the way to do it, and we are doing it on our site.

  • Ibadullah

    @wpbeginner@Ibadullah I am saying when I add the number in post excerpt – I just see the same number on main page. such as I type 50 in the post excerpt field it show Category name : APPLE and instead of content it show number 50

  • wpbeginner

    @Ibadullah That is the whole point of this article.

  • Ibadullah

    It keep showing me the number I add in post excerpt instead of post content!

  • nescafespk

    http://games-masti.com/

    This is very nice trick and thanks for help us and thanks for the whole team of the word press team

  • nescafespk

    <a href=”http://www.games-masti.com” title=”Play Online Games”>Play Online Games</a>

    This is very nice trick and thanks for help us and thanks for the whole team of the word press team

  • Carl

    Great – thanks. Was looking for a simple solution. How do you include a Read more… link after the excerpt also though?

  • Heather

    Thank you for the article. I made the changes in all 3 documents and nothing changed. All of the posts on the blog I am working on were imported from Blogger, could that be an issue or perhaps the theme itself? I am stumped!

    • http://www.wpbeginner.com Editorial Staff

      Nope that can’t be the issue. By changing to the_excerpt it would automatically generate the excerpt.

  • ely

    I can’t seem to find any files containing “php” anywhere on my wp dashboard.

    I’m using dreamhost and the wp 2010 theme. The only files I can find that allow me to edit code are .css files.

    I’m going crazy trying to find a way to create excerpts!

    • http://www.wpbeginner.com Editorial Staff

      Look under Appearence > Editor (There you will find the file)

  • chris h

    thanks! just changing the index.php ‘content’ to ‘excerpt’ did the trick…

  • Technonesia

    My acquaintance is asking for this and I remember to ever saw it here. Thanks, I will forward this to him.

  • http://www.guardraildamageahead.com Scott

    I understand the excerpt thing but how do I then get it to show the image thumbnail along with the excerpt?

  • http://muchosocial.com chris

    Great, I was just looking for an easy way to make use of the excerpts field and be able to define a small intro for each post to be displayed. Thanks a lot.