Created
March 23, 2016 21:10
-
-
Save thagxt/2fff28cbc99ab37f5159 to your computer and use it in GitHub Desktop.
Limit WordPress' the_excerpt to the first full stop / period
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
<?php | |
// Limit WordPress' the_excerpt to the first full stop / period | |
$strings = preg_split('/(\.|!|\?)\s/', strip_tags($post->post_content), 2, PREG_SPLIT_DELIM_CAPTURE); | |
$excerpt = apply_filters('the_excerpt', $strings[0] . $strings[1]); | |
echo $excerpt; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment