Created
February 27, 2019 22:46
-
-
Save trvswgnr/a1ce2d4ddbc862ce741672eea5f96313 to your computer and use it in GitHub Desktop.
use first paragraph for wordpress 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( 'wp_trim_excerpt', 'awesome_excerpt', 10, 2 ); | |
function awesome_excerpt($text, $raw_excerpt) { | |
if( ! $raw_excerpt ) { | |
$content = apply_filters( 'the_content', get_the_content() ); | |
$text = substr( $content, 0, strpos( $content, '</p>' ) + 4 ); | |
} | |
return $text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment