This post is being submitted as part of the tutorial blog writing project over at Daily Blog Tips. If you are interested in participating, all tutorials must be submitted by midnight of January 27th, 2008.
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:
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:
- 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)
- 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.
If you use either of these methods, you’ll notice that your feed is only displaying partial posts. If you’d prefer to have the feed display the entire post, but keep the partial post on your actual website, I recommend using the Full Text RSS Feed WordPress plugin to override this and have the feed display the entire post.
Questions? Let me know in the comments below.