We build easy to manage, secure and Mobile friendly Websites.

How to use the_excerpt() in WordPress


the_excerpt() is a WordPress function that can be used to reduce WordPress post content word length. By default it is set to return 55 words.

We can make the excerpt length to be less than 55 words or more than 55 words.

To change excerpt length to 25 words, add the following code below to your functions.php file in your theme folder.

function theme-name_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'theme-name_excerpt_length')

Add the code below to your php file that will display your post.

<?php the_excerpt(); ?>

This will display your post excerpt up to 25 words.

Leave a Reply

Your email address will not be published. Required fields are marked *