How to Display Post Excerpts in WordPress

By default, WordPress displays the full content of a post on the homepage, archive pages, and other pages where multiple posts are displayed. However, you can display post excerpts instead of the full content by following these steps:

  1. Open the functions.php file of your current WordPress theme, or create a child theme and add a new functions.php file.
  2. Add the following code to the functions.php file:
function custom_excerpt_length( $length ) {
return 20; //change the number of words you want to display in the excerpt
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

function new_excerpt_more( $more ) {
return '...'; //customize the text to be displayed after the excerpt
add_filter('excerpt_more', 'new_excerpt_more');

This code will modify the length of the excerpt to 20 words and add an ellipsis after the excerpt.

  1. Save your changes to the functions.php file.
  2. Edit the post for which you want to display an excerpt. In the post editor, locate the Excerpt meta box. If you don’t see the Excerpt meta box, click on the Screen Options tab in the top right corner of the editor screen and make sure the Excerpt option is checked.
  3. In the Excerpt meta box, enter the text you want to display as the excerpt for the post.
  4. Update the post to save the changes.
  5. Visit the homepage or an archive page where posts are displayed, and you should now see the excerpt instead of the full content.

Repeat steps 4-6 for any other posts you want to display an excerpt for.

Note that if a post doesn’t have an excerpt, WordPress will automatically generate one based on the first 55 words of the post content. You can change this default length by modifying the excerpt_length filter in the functions.php file.