How to Keep your Excerpt Short and Sweet

Posted on 3:25 am 

I’m in the process of updating my theme to a newer version and decided to begin from scratch.  One of the great features I like about Arthemia is the top portion that has the Featured and Headline section.  Unforntunately the Headline section uses the_excerpt() to show a summary of a post.  I say unfortunately because it’s a pain in the ass to have to copy a few lines of text into the excerpt box on the WordPress Post page.  Generally if you don’t put anything in the box, you have no way of limiting how much text is shown when the_excerpt() is displayed.

While searching around for a quick solution I came across this post which has a simple code function you add to your template that allows you to control the length of your excerpt without having to copy text every time you write a new post.

Put the following piece of code in your templates functions.php file:

 $word_limit)
  array_pop($words);
  return implode(' ', $words);
}
?>

Next, put the following piece of code in your template where you want to display the excerpt:


Where 25 is the number of words to display.

Enjoy!

Digg it StumbleUpon del.icio.us Google Yahoo!

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Leave a reply

Comments links could be nofollow free.