← All posts

Custom Excerpt Length in WordPress

1 min read

SeriesWordPress tweakspart 3 of 6
  1. Removing Query Strings from Static Resources
  2. Custom Excerpt More and Custom Excerpt More Link in WordPress
  3. Custom Excerpt Length in WordPress
  4. Inline SVG in WordPress Post
  5. Uploading SVG files through WordPress Media Uploader
  6. Why WordPress restricts uploading SVG files?

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.

custom excerpt length in wordpress

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!