Bold first paragraph of WordPress content
For this WordPress blog, I was looking for a quick PHP snippet on the web to make first paragraph bold, or increase its font size in post contents, like they have in Smashing Magazine website. I found few examples but not everything is clear. I didn't want to use CSS :first-child Selector, because it won't work with older browsers.This code is closest I got, it works great with my current WordPress version 3, but I had to modify the code a little to work with mine. Here's the steps you can follow to make it work in your blog too.Open functions.php located in your installed WordPress folder : root/wp-content/themes/your-theme/ , paste this code right after <?php[cc lang="php"] function first_paragraph($content) { if(is_single()) // make paragraph bold for single pages only { return preg_replace('/]+)?>/', '
', $content, 1); }else{ return $content; } } add_filter('the_content', 'first_paragraph'); [/cc]Now add css code in your theme's css style file.[cc lang="css"] .first_para { font-size:1.1em;font-weight:bold; } [/cc]That's it, now you should see your first paragraph bold in each blog article. Good luck!