Created
June 24, 2018 03:24
-
-
Save aalimran07/99e17337dfdca9d28d0c83f84379f36f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 loanplus_get_excerpt($limit, $source = null){ | |
if($source == "content" ? ($excerpt = get_the_content()) : ($excerpt = get_the_excerpt())); | |
$excerpt = preg_replace(" (\[.*?\])",'',$excerpt); | |
$excerpt = strip_shortcodes($excerpt); | |
$excerpt = strip_tags($excerpt); | |
$excerpt = substr($excerpt, 0, $limit); | |
$excerpt = substr($excerpt, 0, strripos($excerpt, " ")); | |
$excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt)); | |
return $excerpt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment