How to change the last sentence […] of the article excerpt “the_excerpt();” to (read more) etc. with a link, and how to adjust the number of characters [WordPress].

How to change the last sentence [...] of the article excerpt "the_excerpt();" to (read more) etc. with a link, and how to adjust the number of characters [Wordpress]. Wordpress

If you want to place an excerpt in a Wordoress category or archive, you can use the_excerpt();.
But by default, it displays […] at the end of the excerpt, which doesn’t look good or work well…
In this article, I will explain how to change this section with a link to “… Read more” etc. and how to adjust the number of characters in the article excerpt.

Replace […] in the WP excerpt end sentence with (read more)

If you want to change the last sentence of the excerpt […], add the following to functions.php.

The output will look like “Excerpt (Read more)“.
The link url is called by get_permalink($post->ID).
If you don’t need to link them, use
return ‘(Read more)’;
to place the text without linking.
You can, of course, replace the “(read more)” part with any character you like.
And if you don’t place anything in the last sentence, you can use
return ‘ ‘;
and leave the return blank.

Adjust the number of characters in the WP excerpt “the_excerpt();”.

If you use the_excerpt(); to output an article excerpt in WordPress, it will output about 110 characters by default.
There are times when you want to change the number of characters depending on your design.
So here are two ways to change it.

Adjust the length of the excerpt throughout the site.

The first is to adjust the length of the excerpt throughout the site.
In this case, add the following to functions.php.

return 60; will output 60 characters. If you want to change the number of characters, adjust this part.

Adjust the length of excerpts for some parts.

The second way is to add it to functions.php and change the length of the excerpt for each part of each template, instead of setting it for the whole site.
The second way is to change the length of the excerpt for each part of the template.

the top page and the list page, you may want to change the length of this section.
This method can be used in such cases.

<?php the_excerpt(); ? By replacing > with the above, you can change the number of characters.
You can adjust the number of characters by changing the 60 part.
Note that the 0 part indicates the position of the character that starts the excerpt.
This way of writing means that the excerpt is taken from the beginning. If you change the number to 10, then 60 characters will be displayed from the 10th character counting from the beginning.