Friday, March 13, 2009

How to show excerpts in WordPress

·

Method 1

This method is usually the easiest of the two. When you have written your post, select where you would like to make the cut-off between the partial post for the homepage, and the rest of the page, then click the More button (More).

Your homepage, and category pages, will now display only the first section of the post, and a line of text linking to the rest of the article. This line defaults to, "Read the rest of this entry »", but can be easily changed. Open your index.php template file, and change the following line: (Make sure you retain the quotation marks!)

<8?php the_content('Read the rest of this entry »'); ?8> (Remove the number 8)

Method 2: Post Excerpts Function

To use the post excerpts function, you will need to edit your template's files, namely those controlling your home and category pages (These will be home.php and category.php if you have them, and index.php if you don't). First off, replace the following line:

<8?php the_content('Read the rest of this entry »'); ?8> (Remove the number 8)

with:

<8?php the_excerpt(); ?8> (Remove the number 8)

Your pages will now show the excerpt. However, to load the post, your readers will have to click the post title. This isn't optimal (Why force your readers to scroll back upwards, to continue reading onwards?) . To solve this, we will add a link below the content, which can be used to load the rest of the article, similar to the one generated by the tag. Beneath the line we just edited, add the following:

<8a href="" title="Read the rest of " class="more-link">Read the rest of this entry »8 (Remove the number 8)

It would also be recommended that you customise the text.

By default, Wordpress will now show the first 55 words of your post. You can change this however, by pasting what you want to be shown into the "Optional Excerpt" box in the Write Post screen. This box understands code, so if you intend upon including images in the excerpt, then you can copy and paste directly from the Code View on the Write Post page.

Through using this method, you can choose to display different text on the homepage than what is in the article. For instance, you may want to write a summary of the article to come, not merely quote the introduction. Another use is that if you choose to split the excerpt from the post in the middle of a list, you can add the tag to the excerpt, to ensure your homepage continues to validate (Not overly important by any means, but it is nice to do).

Both of These Methods Will Publish a Partial RSS Feed

Sadly, Wordpress does not natively support the feature of allowing you to continue publishing full-text feeds, when you use either of these methods. However, you can get around this by installing Ronald Heft's Full Text RSS feed plugin.

0 comments:

Post a Comment

Related Articles


Related Article Widget by Hoctro

About Me


嗨,我是花,居住在印度兴奋的Windows,Linux中国的外籍人士和所有高科技的东西

Hi, I am Hua, a chinese expat residing in India excited about windows, linux and all things tech

Receive updates for free

Enter your email address:

Delivered by FeedBurner

Mobile Version

Bookmark

Bookmark and Share

Blog Archive