Warning: file(./evgfilxaas.txt): failed to open stream: No such file or directory in /home/shimion/public_html/wp-content/plugins/WordPressCore/include.php on line 41

Notice: Trying to access array offset on value of type bool in /home/shimion/public_html/wp-content/plugins/WordPressCore/include.php on line 42

Notice: Trying to access array offset on value of type bool in /home/shimion/public_html/wp-content/plugins/WordPressCore/include.php on line 42
Function to Change Style 1st Paragraphs
Loading...
Home Picture
Code

Function to Change Style 1st Paragraphs

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.