Let’s say I want to give the first paragraph bold text by adding a body class to the first paragraph. Is there a way to filter the output of
the_content();
or any other paragraph? First paragraph? Last paragraph?
I know I can do this using Javascript or CSS (:firstchild), but is there a native WordPress way?
Thanks.
J
The following bit of code adds a class to the first paragraph output by
the_content
:Add the above to your theme’s functions.php file.
Then in your CSS add something like:
I can’t claim credit for this solution (see this thread in the WP forums) but I tested it and it worked great for me in WordPress 3.3.2. You should be able to modify it as needed to target whichever paragraph your heart desires.