How to Automatically Limit Excerpt Word Count on WordPress Homepage
By default, WordPress uses the <?php the_content(); ?> function to output full post content. When displayed on the homepage, this can take up too much space and affect aesthetics. Is there a way to display only a portion of the content as an excerpt? The answer is yes.
The WordPress text editor includes a built-in more tag. You can add the <!--more--> tag after the part of the article you want to display as an excerpt. However, adding this tag to every article can be tedious. Instead, you can use the following method to fix the excerpt character count.
Locate the index.php file (or possibly content.php) in your theme directory and find the <?php the_content(); ?> function. Replace it with the following code:
<!-- Homepage excerpt display -->
<?php echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 240, "..."); ?>
<span class="more">
<a href="<?php the_permalink() ?>" title="Read more >>
<?php the_title(); ?>" rel="bookmark">Read more >></a>
</span>
<!-- End of homepage excerpt display -->
In the code above, 240 controls the number of characters displayed on the homepage. You can modify this value according to your needs.