Beginners How to customize excerpt length in WordPress

How to customize excerpt length in WordPress

-

If you are 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 excerpt (excerpts) of 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 excerpt (excerpt) is part of a post 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, as sometimes a title is not enough to get the attention of your audience.

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

Using the classic WordPress editor, excerpts can be automatically added to your content by pressing the Read more button. It will add the   <! – more–> tag to the HTML, which you can see in the HTML editor. You can also write a custom message like <! – more Continue Reading! -> ..

Alternatively, you can change the length of this statement according to 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 to guide you through the process.

How to change the length of the statement?

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

Manually change the length of WordPress excerpt

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

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

  1. Hover over the Appearance tab and select Theme Editor.
  2. Open the functions.php file and insert the code:
  1. function my_excerpt_length ($ length) {
  2. return 80;
  3. }
  4. add filter (‘excerpt length’, ‘my_excerpt_length’);
  1. Change the word limit from 80 to whatever number you want and hit the Update File button.

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

  1. While still in the Theme Editor, scroll down until you find template-parts. Below the header, click the content.php file.
  2. Look for the lines:
  1. <div class = “entry-content”>
  2. <? php

Add the following code snippet just below them:

  1. if (is home () || is category () || is archive ()) {
  2. the excerpt (‘‘);
  3. } else {
  1. Find the statements:
  1. ?>
  2. </div> <! -. entry content ->

Then insert the following line over them:

  1. } // end of if statements
  1. Click Update File, and you’re done!

The final result will look something like this:

Change the length of the WordPress excerpt with a plugin

One of the easiest ways to customize the length of the WordPress excerpt is by changing it with a plugin. A recommended option for this task is the Advanced Excerpt 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 extract so that it does not 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 Install Now button, then activate it.

See our other article on how to install plugins for a complete tutorial.

To use the plugin, follow these steps:

  1. Go to the Plugins tab and press Settings under the plugin.
  1. Customize the available options to your liking.
  2. Click the Save Changes button.
WPLegit Staffhttps://wplegit.com
At WPLegit, you will find content on WordPress tutorials with basic information about the platform, its installation and configuration. In addition to links with information about plugins, Web design, SEO, guides and much more.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest news

WHAT IS A BLOG – DEFINITION, TYPES, MAKE MONEY BLOGGING…

Ever come across the big question: what is a Blog? Have you ever wondered what this small but mighty...

Top 5 Free Website Builders – 2021

I’ve been there before, I needed to create a website for my growing business I had no money to...

The 8 SEO techniques to get backlinks or do follow links

To improve your web positioning, there are various SEO techniques that well combined can catapult your website with zero...

How to Install WordPress in 5 Minutes: Tutorial for Beginners

Do you want to create a website or a blog and have been told to do it with WordPress...

How to create a contact form in WordPress. Tutorial Contact Form 7 2021

In today's article I want to show you how to create a contact form in WordPress using the Contact...

The best free image banks to download photos without copyright

If you have just created a blog, are creating a web page or are a community manager that manages...

Must read

Top 5 Free Website Builders – 2021

I’ve been there before, I needed to create a...

The 8 SEO techniques to get backlinks or do follow links

To improve your web positioning, there are various SEO...

You might also likeRELATED
Recommended to you