Created
April 24, 2018 11:29
-
-
Save petersplugins/3d2caeeea51bb7d06d5512ce631e00f1 to your computer and use it in GitHub Desktop.
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
<?php | |
// This code snippet uses the first paragraph of an article as excerpt | |
// use an anonymous function to filter the excerpt | |
// this changes the behavior of the function the_excerpt() to use the first paragraph | |
add_filter( 'wp_trim_excerpt', function( $text, $raw_excerpt ) { | |
$content = apply_filters( 'the_content', get_the_content() ); | |
return substr( $content, 0, strpos( $content, '</p>' ) + 4 ); | |
} ), 10, 2 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment