Created
May 26, 2016 00:04
-
-
Save BruceMcKinnon/8cdac576b6048d9e9f5f4c74ea0c4ba2 to your computer and use it in GitHub Desktop.
WP Provide first sentence only for the excerpt
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
add_filter( | |
'get_the_excerpt', | |
function ($excerpt) { | |
// Split the except into sentances | |
$re = '/(?<=[.!?]|[.!?][\'"])\s+/'; | |
$sentences = preg_split($re, $excerpt, -1, PREG_SPLIT_NO_EMPTY); | |
return $sentences[0]; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment