Skip to content

Instantly share code, notes, and snippets.

View nicdford's full-sized avatar

Nic Ford nicdford

View GitHub Profile
@nicdford
nicdford / Excerpt that strips all the bad stuff, returns just a string
Last active August 29, 2015 14:06
Make shift the_excerpt replacement for Wordpress & Pods templating
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;
}