Created
December 22, 2017 18:56
-
-
Save braginteractive/d01f0fae36027651ce65941de80acee2 to your computer and use it in GitHub Desktop.
Edit the WordPress excerpt to remove everything after the first sentence.
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
/** | |
* Find the first period in the excerpt and remove everything after it. | |
* | |
* | |
* @param string $excerpt The post excerpt. | |
*/ | |
function end_with_sentence($excerpt) { | |
return substr($excerpt,0,strpos($excerpt,'.')+1); | |
} | |
add_filter( 'the_excerpt', 'end_with_sentence'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment