How to customize excerpt length in WordPress

If you’re a WordPress user, you already know that the WordPress theme and core automate many of the functions that dictate how your content is displayed. A common example is how pages display excerpts (excerpts) from your articles. But did you know that you can customize the length of the WordPress excerpt? This tutorial explains how you can do it!

What is the excerpt in WordPress?

An extract (excerpt) is part of a publication that links to the full article. It is used to interest readers and make them want to read more. It helps to highlight the key points of your content, since sometimes a title is not enough to grab the attention of your audience.

By default, WordPress limits excerpts to the first 55 words of your post.

When using the classic WordPress editor, excerpts can be automatically added to your content by pressing the button Read more. will add the tag to HTML, which you can see in the HTML editor. You can also write a custom message like ..

Alternatively, you can change the length of this excerpt to suit your needs. Providing more text can draw readers’ attention to the article.

There are different ways to do this task. Below you will find instructions that will guide you through the process.

How to change the length of the excerpt?

The two most common ways to change the excerpt length are manually or using a WordPress plugin.

Manually change WordPress excerpt length

The manual method involves adjusting the code. However, you don’t need to have deep knowledge of any programming language to do this.

See also  GraphQL vs. REST: which is the best for API development?

Here are the steps to manually change the length of an excerpt:

  1. Hover over the tab Appearance and select theme editor.
  2. open the file functions.php and insert the code: function my_excerpt_length($length){ return 80; } add_filter(‘excerpt_length’, ‘my_excerpt_length’);
  3. Change the word limit from 80 to any number you want and press the button update file.

In some themes, like Twenty Sixteen WordPress, you will also need to edit the content.php. Follow the steps below to do so:

  1. Being still the theme editorscroll down until you find template-parts. Below the header, click the file content.php.
  2. Look for the lines:
    Add the following code snippet just below them:

    if ( is_home() || is_category()||is_archive()){ the_excerpt(”); }else{

  3. Find the declarations: ?>

Then insert the following line above them:

} // end of if statements

  • click on update fileand ready!
  • The end result will look something like this:

    Change WordPress excerpt length with a plugin

    One of the easiest ways to customize the WordPress excerpt length is by changing it with a plugin. A recommended option for this task is the plugin . It is free and easy to use.

    By using the plugin, you can:

    • Trim the excerpt by number of words or characters.
    • Add a “Read More” link and customize it.
    • Complete the last word of the excerpt so that it doesn’t end halfway.
    • Keep the HTML markup and choose which tags to include.

    To install it, hover your mouse over plugins in your WordPress Dashboard and press add new. Type “advanced excerpt plugin” in the keyword bar. Click the button Install Nowlater activate it.

    Check out our other article on for a full tutorial.

    To use the plugin, follow these steps:

    1. Go to the tab plugins and press Settings below the plugin.
    2. Customize the available options to your liking.
    3. Click the button Save Changes.

    conclusion

    One of the points that contribute to provoke the curiosity of a reader towards an article is the extract. When using WordPress, you can change the default excerpt length in two ways:

    1. manually: inserting a few lines of code in the file function.php of a theme.
    2. Using a plugin: installing the plugin and configuring it.

    If you have any questions, leave them in the comments section.

    Deyi is a digital marketing enthusiast, with a background in web design, content creation, copywriting, and SEO. She is part of ‘s SEO & Localization team. In her free time, she likes to develop projects, read a book or watch a good movie.

    Loading Facebook Comments ...
    Loading Disqus Comments ...