Scroll Down
/**
* code #6 - append 'first' class onto the 1st
element in each post
* source - http://byjakewithlove.com/
* @param string
* @return string
*/
function first_paragraph($c犀利士
ontent){
global $post;
if ($post->post_type == "post") {
return preg_replace('/<p([^>]+)?>/', '<p$1 class="first">', $content, 1);
}
else {
return $content;
}
}
add_filter('the_content', 'first_paragraph');
I have included this feature which I originally styled for my own blog but have been using it frequently in other WordPress themes. You should add this code into your functions.php and then create some CSS styles to match. Target the class .first or p.first if you need to specify an element.