
There is more than one way to change the excerpt length in a WordPress Post.
I collected all the working methods to change the default excerpt (55) to whatever you need.
Solution 1 – Excerpt length in “wp-includes”
PROS: Fast and easy.
CONS: This will be applied to every category and archive, including the blog homepage.
Source: It’s Called Web Design
Go into “wp-includes/formatting.php”, line 1333 (line 853 for version prior to 2.7).
Change “55″ according to your needs.
Solution 2 – Excerpt length using Filters in “functions.php”
PROS: You can freely change the excerpt length in each category, archive or on your blog homepage.
CONS: A basic skill in WP and PHP is required.
Source: WordPress Codex
STEP 1. You can change the excerpt length using excerpt_length filter. Just add the following code into the “wp-content/themes/THEME_NAME/functions.php” file:
1 2 3 4 5 6 |
<?php
function new_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');
?>
|
You are done! Step 2 is no longer needed.
STEP 2. Add the following code into the entry/post div (“index.php“, “archive.php“)
1 |
<?php the_content_limit(200, "Read more →") ?>
|
instead of
1 |
<?php the_content(); ?>
|
You can write whatever you want insted of “200” and “Read more →”. Eg. (120, “Want to know more about it?”).
Solution 3 – Excerpt length using the “Excerpt Plugin”
PROS: Easy to use.
CONS: A basic skill in WP and PHP is required.
Source: Download from guff.szub.net
Set the excerpt length using the Excerpt Reloaded plugin. Simple theme editing is required.
Parameters:
- excerpt_length (integer) – Number of words to display. Default is 120.
- allowedtags (string) – Defines HTML tags. Default is ‘<a>’.
- filter_type (string) – Defines how WP should filter the content. Options are based on tags: ‘content’, ‘content_rss’, ‘excerpt’, ‘excerpt_rss’. Set to ‘none’ to display raw content. Default is ‘excerpt’.
- use_more_link (boolean) – Display the “more” link (TRUE) or (FALSE). Defaults to TRUE.
- more_link_text (string) – Define the text used for the link. Default is ‘(more…)’.
- Other functions: force_more_link (boolean) – fakeit (integer) – fix_tags (boolean).
Happy coding! 🙂
[…] The manual Excerpt in WordPress Ultimate Guide to WordPress SEO – META Descriptions How to use the Excerpt field from WordPress for SEO WordPress meta description using post excerpt, category description and post ID The WordPress excerpt: What, why, how, tips and plugins Using WordPress Excerpts Change excerpt length in wordpress […]
Thanks, been searching all day for something like this (solution 2). But I couldn’t get it to work properly before I included the tricks from this site:
http://www.webwalkersolutions.com/how-to-fix-wordpress-fatal-error-call-to-undefined-function-the_content_limit-in
[…] The manual Excerpt in WordPress Ultimate Guide to WordPress SEO – META Descriptions How to use the Excerpt field from WordPress for SEO WordPress meta description using post excerpt, category description and post ID The WordPress excerpt: What, why, how, tips and plugins Using WordPress Excerpts Change excerpt length in wordpress […]