Quick tip: Use wp_trim_words() to limit words in WordPress

By admin / 10:13 pm, 26 Jun 2016 / Wordpress / 0 Comment

Using wp_trim_words() allows us to limit the title and excerpt, and anything else really, to a particular number of words. You can define the number of words to limit them to, and also define what you’d like the “more” text to be.

WordPress 3.3 brought a handy little function with it in wp_trim_words(). An example use case is a height limited box like the one pictured, where you want to make sure that the title and excerpt don’t cause the text to overflow the box.

Previous Post
Next Post