php - How can I limit the word count for get_the_content() on wordpress? -
i'm trying limit string output of get_the_content can't find anywhere on net on how this.
everything find regarding the_content().
i'm not using the_content because want string unformatted , because reason doesn't seem work right on loop posts have.
anyways, no how make get_the_content return specified number of characters of actual description? don't want resort using excerpt reserved other information i'm using.
i haven't tested think work..
go wp-includes/post-template.php
find get_the_content() function
at end of function, there is
return $output;
before final line, add
$output = preg_replace("/((\s+\s+){1,13}).*/s","\\1",strip_tags($output));
so you're left with
$output = preg_replace("/((\s+\s+){1,13}).*/s","\\1",strip_tags($output)); return $output;
the part you'll want change number "13" in code above - put number of words want display
let me know how works you
Comments
Post a Comment