display post excerpts in WordPress theme og

Do you want to know how to make your WordPress theme display post excerpts?

You may increase pageviews, minimize loading times, and provide your users a better experience by presenting post excerpts instead of the whole article on your site.

We’ll teach you how to effortlessly add post excerpts to your WordPress theme in this article.

How to display post excerpts in WordPress themes

Why do you want to see excerpts from your posts in WordPress?

To avoid displaying the complete content of every item on your WordPress site, post excerpts are widely used on blog index and archive pages.

By default, WordPress will display entire posts on your website’s main page, blog page, and archive pages. Although WordPress has built-in support for showing post excerpts, not every theme will use it.

Because only a fraction of each item is loaded, using excerpts can make WordPress load faster.

Additionally, because your visitors will have numerous blog posts to pick from rather than a single large post, it may enhance your pageviews.

So, let’s have a look at how to display post excerpts in your WordPress theme.

Check to see if your WordPress theme allows you to use post excerpts.

The majority of popular WordPress themes already include built-in options for displaying excerpts of your writings.

This may be found in your WordPress theme options panel or by navigating to Appearance » Customize and selecting the ‘Blog’ menu option from the drop-down menu.

Go to WordPress customizer click blog

This will take you to a screen where you may change the settings for your WordPress blog and archive page.

Simply select the ‘Blog/Archive’ menu item from the menu bar.

Click blog and archive menu option

After that, scroll down to the ‘Post Content’ area at the bottom of the menu.

Then select ‘Excerpt’ from the drop-down menu.

Turn on post excerpt option

That concludes our discussion. Remember to save your changes by clicking the ‘Publish’ button.

This will allow your WordPress theme to display post excerpts. The menu selections may alter significantly depending on the theme you’re using.

 

Add Code to WordPress to Show Excerpts from Posts

If your theme doesn’t support post excerpts by default, you’ll have to manually include it.

You can manually alter the files in your WordPress theme, but we recommend establishing a child theme. That way, if you upgrade your WordPress theme, the modifications you’ve made won’t be lost.

See our beginner’s guide on creating a WordPress child theme for more information.

You’ll need to pick the right template for the pages where you want to display post snippets after you’ve developed your child theme. This will be home.php, content.php, category.php, and archive.php for most themes.

See our beginner’s guide to WordPress template hierarchy for help locating the correct template file to update.

Following that, look for the following code in each of the files:

1
<?php the_content(); ?>

 

Then, as shown in the code below, replace it with the excerpt tag:

1
<?php the_excerpt(); ?>

 

Your post excerpts will appear where the whole article used to be when you save your files.

Change the WordPress Excerpt Length by Default

You might wish to adjust the length of your post excerpts once you’ve added them to your WordPress theme. WordPress will add an ellipsis (…) to the end of the first 55 words of the post by default.

This can be changed by inserting code into your WordPress files. If this is your first time, check out our beginner’s guide to pasting web snippets into WordPress.

Then, either in your functions.php file, a site-specific plugin, or by using a code snippets plugin, add the following code.

1
2
3
4
5
6
7
8
9
10
11
// Changing excerpt length
function new_excerpt_length($length) {
return 100;
}
add_filter('excerpt_length', 'new_excerpt_length');
// Changing excerpt more
function new_excerpt_more($more) {
return '...';
}
add_filter('excerpt_more', 'new_excerpt_more');

This code reduces the length of the post excerpt to 100 characters. You can alter the ‘100’ to whatever character length you choose.

If you want to personalize your post excerpts even further, check out our guide on how to customize WordPress excerpts without coding.

We hope that this article has shown you how to use WordPress themes to display post excerpts. You might also be interested in our guide to selecting the best web design software and our expert selections for the best small company payroll software.

Leave a Reply