Last active
August 29, 2015 14:06
-
-
Save nicdford/6f7c36c3cf4e6f401768 to your computer and use it in GitHub Desktop.
Make shift the_excerpt replacement for Wordpress & Pods templating
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment