BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

How to change post excerpt length in wordpress

By Chaitanya Singh | Filed Under: WordPress

We already shared how to display post excerpts in WordPress themes. By default WordPress shows only 55 words as an excerpt. This post is to discuss, how to change the length of post excerpts in WordPress and what are the advantages of doing so.

change post excerpt length in wordpress

Why you need to change the default  length of excerpts?

Default length is 55 words but sometimes 55 words aren’t enough to give a meaningful gist to the content. In such scenarios, you should change it to give a better idea to the readers about the post’s content. There are two popular ways to do it as explained below:

There are two methods to change the except length:

  1. Manual method
  2. Using WordPress plugin

Manual method

Open the theme’s functions.php file and add the below code. It would change the default limit of 55 words to the new words limit of 120.

/* New excerpt length of 120 words*/
function my_excerpt_length($length) {
return 120;
}
add_filter('excerpt_length', 'my_excerpt_length');

If you are not ok with the limit of 120, you can change to to any integer number you like. For example, if you want the excerpt length of 150 words rather than 120 then the above code can be re-written as:

/* Changed excerpt length to 150 words*/
function my_excerpt_length($length) {
return 150;
}
add_filter('excerpt_length', 'my_excerpt_length');

Using WordPress plugin

If you do not prefer to edit the theme’s files then you always have a option to use the plugins, which does the job for you. For changing the excerpt length we have a plugin called advanced excerpt, which provides the feature to customize the excerpt length along with few more advanced features, which makes your post excerpts look attractive. Download advanced excerpt plugin and install it.

Conclusion

It is always good to change the default excerpt length to make the excerpt somewhat meaningful so that the users can understand the content just by looking at the excerpt.  We always prefer to do the things without using plugins but we have provided both the methods so that even if you are not comfortable with the coding stuff, you would be able to do the things by using a plugin.

Let us know if you need any further help on this. Do let us know if you have any other method of changing the excerpt length in WordPress, share your thoughts via comments.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap