Display Post Excerpts in WordPress

WordPress is the simplest way to create a website or a blog.

I have used Squarespace, Drupal, Octopress and built from scratch. These have their pros and cons.

When you setup your WordPress site, by default the home becomes a blog feed.

Usually this feed has the full text of a blog post.

The benefits of having excerpts instead of full text are:

  1. It decreases page load time
  2. It increases page view count

These benefits are explained in more detailed in this post about how to display post excerpts in WordPress themes

Making this change is not so easy to spot. It’s not part of the Settings in WordPress and it is possible that you have excerpts not showing up.

You need to edit these 3 files:

  • index.php
  • archive.php
  • category.php

In the Admin section of WordPress go to Appearance, then Editor:

Wordpress Template Editor

If you are using WordPress it is important to learn some code.

You need to look for the code: <? php the_content(); ?>

And replace it with the code: < ? php the_excerpt(); ?>

How To show Post Excerpts

Edit Index.php To Display Post Excerpt

No matter what theme you are using, the name index.php will appear in parenthesis:

Wordpress Editor index php file

Click on that file and use Find to search the text “the_content”

Depending on your theme you might find it or not.

In my case I am using the Theme “Sparkling” and I cannot find such line. But I found the following:

Wordpress Editor Index the_content

This code translate to “Get each blog post and create a list of them”.

Don’t be afraid of code.

It says: while there are posts put a post.

Then it says: Include the post format, if you want to modify it then add some file…etc.

The next line says get_template_part( 'content', get_post_format() );

If you read it like this it makes sense: Get the template, get me the content and the post format.

We need to change a code that says the_content to the_excerpt

We are trying to change the format of the post content, from “showing me the whole content” to “show me only an excerpt”

The previous code gives me some clues. If I want to change the format I need to edit some other file and it starts with the word “content”.

Keep in mind that this is particular for the Sparkling WordPress theme but the same process can be applied for your theme.

Looking at my editor I found the following files:

Wordpress editor content files to edit the post format

Edit The content.php File

Find a line that says the_content

This file has both “the_content” and “the_excerpt”:

Wordpress Editor Sparkling Theme Content.php

We are lucky. The developer left some notes there so we could understand it better.

It says only to show Excerpts when using Search. Then it has an “else” as in: Only show Excerpt when using Search otherwise show the whole Content.

Let’s change “the_content” to “the_excerpt”. Then click on “Update File”.

Now go to your site and you will see that your Home page shows only Excerpts of each blog post.

Edit Archive.php To Display Post Excerpt

This file shows a similar code that the index.php. It calls some other file to get the format of the posts. In this case it is calling the file content.php.

Manual or Automatic Excerpt

Automatic Excerpt will show the first 55 words, while manual excerpt can be added for each post. If you don’t see this field. Go to the top of the post:

Wordpress screen options button

Check the box “Excerpt” and you will see the following field appear towards the bottom of the post:

Wordpress manual excerpt for a post

This is how it looks published on the home page:

Wordpress manual excerpt home page

 

Please Post a Comment or Connect with me on Twitter and send me a Tweet


Related Post

Go to the Previous Directory in Vim I use Vim. Vim is the most productive text editor if you know some vim commands When I open a file and I am done with it. I often want to go...
Export Data From Firebird Database to CSV File Background Some software applications use a database called Firebird. This is an open source database. If the software application is compiled you ca...
Fix Blank Screen in WordPress Admin One day. You login to your wp-admin in your website. And… Blank page. If you can see the navigation bar on the left but you see a blank pa...
Installing Hipchat on Ubuntu Tested on: Ubuntu 12.04 LTS Thinkpad T400, 2GB RAM Intel Core 2 Duo CPU P8600, 32bit Sources: Official hipchat linux instructions Ask U...

4 thoughts on “Display Post Excerpts in WordPress

  1. sunilpatro1985 Reply

    When followed the above steps, my blog shows excerpts only, even when I click on continue reading, it shows summary only, please guide, thanks

  2. Kristina Reply

    Thank you, Tom. Until today, our 15 year old site was displaying post excerpts, and then after what supposed to be an unrelated plug-in update, all the excerpts disappeared and full text was displayed. This quick fix solved the immediate problem. Now why our theme’s index file change, with no update to the theme … bears investigating! But thanks for the fast fix.

Leave a Reply