This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function trim_content( $post_content, $length ) { | |
if (strlen($post_content) > $length) { // check to make sure your content is longer than what you want to display | |
$post_content = wordwrap($post_content, $length, "<br /><br />"); // Set br's to trim the content to the nearest whole word | |
$post_content = substr($post_content, 0, strpos($post_content, "<br /><br />")); // trim content | |
$post_content = strip_shortcodes( $post_content ); // strip shortcodes for wordpress content with shortcodes | |
return $post_content; | |
} |
NewerOlder