How to trim the_excerpt to a certain character count

How to set count for the_excerpt function in symbols?

We are know, for create excerpt of posts in WordPress, used function the_excerpt. This function, by default output first 55 words of content (post). Ok, but how make, if we need set limit quantity text not words, but symbols? For example, we need output first 120 symbols of the post, how make it? On the Internet, you can find many variants, but all of them don’t satisfy me, so how suggest work in loop or need of edit template/theme, but is not always practical and aesthetics of the code is lost 🙂 The answer, that I propose enough simple and concise, it contain only 4 lines of the code, that need put in your functions.php file.

In addition, I think it would be good, if I will write here more some functions, that override default works for the_excerpt and that used, practical on each projects: change quantity words for the_excerpt, remove dots (...) on the end of excerpt, add link on the post, on the end of excerpt:


Leave Comment

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