WordPress Excerpts Limit
In most WordPress themes, an excerpt of each post is displayed by default, rather than the full post content. Themes use the excerpt generator, a core part of WordPress's configuration system. The WordPress excerpt limit is 55 words by default; the 55th word is followed by an ellipsis and a "Read More" link. Some users prefer to either lengthen or shorten the default excerpt limit. You have several options for doing this.
-
Changing the Excerpt Limit Manually
-
Because the excerpt limit is programmed into the WordPress core configuration file, directly editing the file isn't recommended. This could cause problems when you update to newer versions of WordPress. The best way to manually change the excerpt limit is to edit your theme's "Functions.php" file. This overrides the default excerpt limit.
Add the following code to your theme's Functions file. Replace the "XX" value with the desired excerpt length (by word count):
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'custom_trim_excerpt');function custom_trim_excerpt($text) { // Fakes an excerpt if needed
global $post;
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$excerpt_length = XX;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, '...');
$text = implode(' ', $words);
}
}
return $text;
}
Changing the Excerpt Limit With Plug-ins
-
If you aren't familiar with PHP, try a WordPress plug-in to change the excerpt limit. Several, such as Excerpt Editor, Advanced Excerpt and Easy Excerpt, offer an easy-to-use interface that lets you set the excerpt length without any coding necessary. Click "Plugins" within the WordPress dashboard to search for and install an excerpt editor.
-
Displaying the Excerpt Manually
-
If you prefer, you can remove automatic excerpts altogether by removing the "Excerpt" function from your theme. When you do this, the full post content is displayed in your loop automatically. You can then use the "More" tag create a manual excerpt.
Open your theme editor and open the "Single.php" file. Locate the following line of PHP:
<? php the_excerpt(); ?>
Change it to:
<? php the_content(); ?>
Using the More Tag
-
If you edit your Single.php theme file to automatically display the full post content and want to manually choose the excerpt cut-off, you can do so inside the post editor. Click the post you want to edit and move your cursor to the desired cut-off point.
Click the page separator icon to insert the "More" tag. All content before this tag becomes the manually generated excerpt. If you use the HTML editor rather than the visual editor, use the following short code to generate the "More" tag: <!--more-->
-