I’m using WordPress 3.9.2, and having trouble with the wp_trim_words
function. It seems to be cutting the string down to X characters instead of X words.
Example
Put the following in a template file:
<?php
$str = "Imagine discovering a secret language spoken only online by a knowledgeable and learned few. Over a period of weeks, as you begin to tease out the meaning of this curious tongue and ponder its purpose, the language appears to shift in subtle but fantastic ways, remaking itself daily before your eyes. And just when you are poised to share your findings with the rest of the world, the entire thing vanishes.";
$str_excerpt = wp_trim_words($str, $num_words = 5, $more="..." );
echo $str_excerpt;
?>
In my browser, I see the output as Imagi...
. That’s not how it should function though, as far as I read from the docs:
Description
This function trims text to a certain number of words and
returns the trimmed text.Usage
$trimmed = wp_trim_words( $text, $num_words = 55, $more = null);
Is there a setting or perhaps something in the theme I’m using that’s causing this behavior?