You are using an outdated & insecure version of Internet Explorer. Certain features of this website will not function correctly. Please consider upgrading.

Let's get in touch

Digital Alchemy. Human Experiences.

I love that I can still learn new little features about a system I’ve been developing for, for almost 10 years.

WordPress has a nifty little function, wp_trim_words() which does as you might expect: trim’s a specified string to a set number of words.

Usage

It’s also worth noting that this function is localized, meaning that for East Asian languages where a single character is actually a word, the function will still work as expected.

There’s actually a plethora of built-in utility functions like this built into WordPress which can be explored in/wp-includes/formatting.php.

Sources


Next:

What We do