Last active
December 14, 2015 03:18
-
-
Save gyrus/5020064 to your computer and use it in GitHub Desktop.
Output WordPress content with a class on the first para
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 | |
| /** | |
| * Output content with a class on the first para | |
| * | |
| * @param string $class Default: 'intro' | |
| * @return void | |
| */ | |
| function pilau_the_content_first_para_class( $class = 'intro' ) { | |
| $content = apply_filters( 'the_content', get_the_content() ); | |
| echo preg_replace( '/<p([^>]+)?>/', '<p$1 class="' . $class . '">', $content, 1 ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment