Created
June 9, 2016 12:24
-
-
Save TheHeat/8618012dbd2318572504cd631612890a to your computer and use it in GitHub Desktop.
Convert text to usable excerpts outside the loop
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
<?php | |
// Cleans up and shortens text | |
// for creating excerpt when custom excerpts aren't available | |
// Wrapper around wp_trim_words with added shortcode removal | |
function proper_make_excerpt($content, $count = 50, $more = '…'){ | |
// remove shortcodes first so we don't include them in our count | |
$content = strip_shortcodes( $content ); | |
// trim to taste | |
$content = wp_trim_words( $content, $count, $more ); | |
return $content; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment