Excerpts are a great way to invite visitors to read your articles. Unfortunately, not all themes support this feature. But worry not! You can go around this little setback by inserting the_excerpt() function into your theme’s template files.
Although setting up the function will require you to do a little coding, I assure you it’s actually not that hard. Just follow the instructions in this article, and your site will display excerpts in no time!
Introduction to the WordPress Excerpt
An excerpt is a brief summary of your article that allows the readers to know what to expect from the post. Just like a teaser to a movie, it lets them decide whether they’re interested in reading the whole article or not.
If you’ve seen plenty of blogs before, chances are you have seen how excerpts look like. They usually appear in blog index pages, just like the one below:
There are two methods that you can use to display excerpts on your WordPress page without having to use the_excerpt function:
- Automatic excerpts. By default, WordPress will select the first 55 words (or more) of your article and use them as the excerpt.
- Manual excerpts. If you prefer to create your own excerpt, you can do so by navigating to Posts -> Add New. Click Screen Option and tick the Excerpt box.
After that, a new box named Excerpt should appear below your WordPress editor. Use this box to write custom excerpts.
How to Display Excerpts Using the_excerpt() Function
As mentioned before, some themes can’t display excerpts. As a consequence, your blog index pages will show the full content of each post instead of the summaries. Not so pretty, isn’t it?
To know whether your theme supports excerpts or not, go to Dashboard -> Appearances and look for the excerpt option under the post or layout settings.
Do you find a similar option like the one shown above? If yes, simply tick the box and your excerpts will appear. However, if you don’t, get ready to insert the_excerpt function into the theme’s template file.
Unfortunately, because each theme is coded a little differently, there’s a chance that this method won’t work. So before we go on, don’t forget to create a backup first. You might also want to apply the function on a child theme so your changes won’t disappear when the theme is updated.
With that in mind, let’s get started! Here’s how you do it:
- Go to the theme template files. You can either do that from the WordPress dashboard (Appearance -> Theme Editor), or you can access the File Manager from your control panel (wp-content/themes/name-of-the-theme).
- Locate the_content() template tag in your theme files. This may be the most tricky part since each theme has it in different locations. Try to look for it in index.php, archive,php, or categories.php. Press CTRL + F to make the search easier. If you still can’t find it, try to search from the files under the template-parts section.
- Replace the_content() with the_excerpt(). Once you find the_content tag (there should only be one of them), just erase it and type in the_excerpt.
- Save the file, and you’re all set. Click Update File and wait until it shows “File updated successfully”. Then, check out your site now – it should display excerpts with three little dots in a bracket at the end.
That was quite a ride, wasn’t it? But now that you have successfully edited your theme template files, your blog index page will no longer show a wall of text. Visitors will be happy to browse through your articles!
If you run into trouble when applying the_excerpt() function, feel free to drop a comment below.