How to Set Up Automatic Excerpt Generation in WordPress

jiuyi
Administrator
240
Posts
0
Fans
Support & TroubleshootingComments22Characters 320Views1min4sRead
WordPress by default displays the first portion of your post content as an excerpt on the homepage and archive pages. You can use several more flexible methods to control how excerpts are generated. Below are common solutions:

1. Manually set excerpts via the Excerpt field

When editing a post, locate the Excerpt module in the Document panel on the right sidebar. If it is not visible, enable it via the three-dot menu at the top right → PreferencesPanels.
Enter your desired excerpt text here, and WordPress will prioritize this custom content as the post excerpt.

2. Auto-extract the first 55 words (default behavior)

If you leave the Excerpt field blank, WordPress will automatically call the the_excerpt() function, which extracts the first 55 words from the post body and appends an ellipsis. This is native behavior from WordPress core and works out of the box with most themes.
Ensure your theme templates (e.g. index.php, archive.php) use this tag:
<?php the_excerpt(); ?>
Do not use the tag below, as it outputs the full post content instead of a trimmed summary:
<?php the_content(); ?>

3. Customize the auto-excerpt length

If you want to adjust the number of words extracted, add the following code to your theme’s functions.php file:
function custom_excerpt_length( $length ) {
    return 20; // change to your desired word count
}
add_filter( 'excerpt_length', 'custom_excerpt_length' );

4. Customize the excerpt more text

The default ending marker is […]. You can replace it with custom text by adding this code to functions.php:
function custom_excerpt_more( $more ) {
    return '... continue reading';
}
add_filter( 'excerpt_more', 'custom_excerpt_more' );

That covers the main methods. You can write manual excerpts for better presentation, or let the system generate them automatically. The key is to make sure your templates call the_excerpt(), and adjust the length and ending style as needed. The setup is straightforward, but small details are easy to miss.

 
jiuyi
  • by Published onJune 22, 2026
  • Please be sure to keep the original link when reposting.:https://www.wptroubleshoot.com/wordpress-automatic-excerpt-setup/

Comment