Anonymous User 7842110
(@anonymized-7842110)
You can also do this using CSS and apply it globally (so you don’t have to manually add the strong tag each time).
The CSS for this will look something like …
.post-description { font-weight: bold; }
If you’d like me to give you the exact code, please post a link to your site 🙂
Hi Jimmy,
thanks for the quick reply.
The following link leads to a post on my site, wehere the bold text next to the picture is now made bold manually: http://waternatuurlijkgrootsalland.nl/dijkwachter/
Anonymous User 7842110
(@anonymized-7842110)
OK, so you could use …
.single-post .inner .entry-inner p:first-child { font-weight: bold; }
This rule applies to the first <p>
tag in a single post.
Give it a shot and let me know how it goes.
Hi Jimmy,
sorry, it does not work. I tried a test post both with and without an image, to see if that makes a difference, but it doesn’t. I also cleared the cache, to be sure, but that doesn’t change.
Do you have any other suggestions?
Anonymous User 7842110
(@anonymized-7842110)
Hi,
I’ve just spent a few minutes trying to get it to work in my browser and it’s not playing nice.
I think the issue’ve got is that the the first <p>
tag has a child <a>
of its own, so the CSS is applying it to that.
We need to be able to give that first paragraph its own CSS class. Here’s a nice solution … https://wordpress.org/support/topic/automatically-bold-first-paragraph-of-content?replies=5
I’ve pasted the code below (this needs to go in your functions.php file) …
function first_paragraph($content){
return preg_replace('/<p([^>]+)?>/', '<p$1 class="lead">', $content, 1);
}
add_filter('the_content', 'first_paragraph');
After that, you would just need to add the following to your CSS …
.single-post p.lead { font-weight: bold; }
Hi Jimmy,
you’re brilliant, it works! Thanks a lot! Saves me a lot of revisions.