The following code will enable you to limit the number of words to show on your post excerpts.

1. Paste this to your functions.php

<?php
function word_count($string, $limit) {
$words = explode(' ', $string);
return implode(' ', array_slice($words, 0, $limit));
}
?>

2. Paste this to your index.php, or wherever you want to show your customize excerpt.

<?php echo word_count(get_the_excerpt(), '30'); ?>

Just change the number ’30’ to the number of words you want to appear on your excerpt.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s