Custom Excerpt Length in WordPress
In WordPress, excerpt means a _short extract from the blog post. _The default length of the excerpt in WordPress is 55 characters. For the customisation purposes setting user defined length to the excerpt in WordPress is needed at times. This needs adding a small php function in to functions.php file. As mentioned above default length of the excerpt is 55 characters, to override the default functionality excerpt length we have to add a filter in the same file.
Add the following function and filter in your functions.php file to get the custom excerpt length in WordPress.
//Custom Excerpt Length
function custom_excerpt_length( $length ) {
return 35; // Setting the custom excerpt length in WordPress
}
//Adding a filter to override the default method excerpt length of WordPress
add_filter('excerpt_length', 'custom_excerpt_length', 999 );```
Thats all we have to for setting the custom excerpt length in WordPress. Happy Exploring and Happy Learning!
Enjoy Reading This Article?
Here are some more articles you might like to read next: