Created
July 21, 2012 20:55
-
-
Save gyrus/3157161 to your computer and use it in GitHub Desktop.
Output first paragraph of WordPress content
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 | |
/** | |
* Output first paragraph of WordPress content | |
* | |
* @uses get_the_content() | |
*/ | |
function pilau_the_content_first_paragraph() { | |
$content = trim( apply_filters( 'the_content', get_the_content() ) ); | |
preg_match( '#<[a-z]+>[^<]+</[a-z]+>#', $content, $matches ); | |
echo $matches[0]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment