Created
May 18, 2013 04:25
-
-
Save iscat/5603242 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 | |
/* Add Class to first Paragraph in WordPress the_content(); | |
Source: http://webdevbits.com/wordpress/add-class-to-first-paragraph-in-wordpress-the_content/ | |
------------------------------------------------------------------------------------------- */ | |
function first_paragraph($content){ | |
if ( is_page() || ('school' == get_post_type() ) ) { | |
return preg_replace('/<p([^>]+)?>/', '<p$1>', $content, 1); | |
} else { | |
return preg_replace('/<p([^>]+)?>/', '<p$1 class="intro">', $content, 1); | |
} | |
} | |
add_filter('the_content', 'first_paragraph'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment