Customize or Modify the WordPress Post Excerpt

WordPress comes with own functions, such as get_the_excerpt() or the_excerpt(), to output a short version of the post content. This short description can be entered individually for each post.

How can I change the length of the excerpt?

A short description may be slightly longer or shorter depending on the post. If the post excerpt is used in post lists, it makes sense to adjust content length of the excerpt. In this case we can use the WordPress filter excerpt_length.

To do this, add the following code snippet to the functions.php of your WordPress theme:

How can I extend or customize the excerpt?

If you want to append a suffix to the post excerpt, for example, we can use the WordPress filter excerpt_more. This is useful if we want to end our post excerpt with a suffix like “…” or we want to insert a “Read more” button at the end of the text.

For example, add the following code snippet to your theme’s functions.php file, to append the shortened post excerpt with “…”:

Or use the following code snippets to include a read more button:

With these two WordPress filters, the post excerpt can be easily customized and extended.