Showing Only a Post Excerpt in WordPress

May 6, 2008 · Print This Article

Depending on the type of blog you run, you may at some point have an interest in only showing only a short excerpt of a post on your blog’s homepage. This could be for a variety of reasons, ranging from attempting to increase page views to trying to make your homepage more easily navigated and organized.

Another really popular place for using the post excerpt is for your archive pages, which helps you to avoid being penalized for duplicate content by the search engine spiders.

No matter what the reason is, if you are interested in switching some of your templates to show post excerpts, it isn’t very difficult to do. Go to the template you want to make the change on and find the following code:

< ?php the_content(); ?>

Depending on your theme, it may include something in the parenthesis. Change this code to the following:

< ?php the_excerpt(); ?>

This will cause your blog theme to only display the first 55 words (and strip pictures/formatting). If you’d like to add a link to allow readers to then click over and read the full post, you can instead use something like the following excerpt code:

<?php the_excerpt(__(’Continue Reading This Entry’));?>

You can of course adjust the wording to fit your personal needs.

If you’d prefer to show an excerpt longer than 55 words, or want to display your pictures and formating, you’ll have to do a little manual work. You currently have two choices:

  1. Use the More tag – Once you’ve written your post, you can switch over to Code view in your WordPress Write panel, click where you want the excerpt to stop and click the More button.  (See the screenshot above)
  2. Optional Excerpt field – Paste the part of the post you’d like to display as an excerpt in this field of your WordPress Write panel. It should correctly display everything in the excerpt including links and specific formating.

Your choice for site templates and wordpress themes


Got something to say?

You must be logged in to post a comment.