I have a WordPress blog and I would like to bold a random sentence between H2s,
Ideally, the PHP would dynamically take a random sentence (maybe using regex to find anything between a . or ?) and add a <b> </b>
at the beginning and end of that sentence. Can this be achieved with PHP?
Below is an example of what I'd like to achieve, but of course, done dynamically using PHP, so I don't have to manually go into all my posts and. bold these sentences.
<h2>What is coffee?</h2>
<p><b>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</b>. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat .</p>
<h2>How is coffee made?</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. <b>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</b> Excepteur laborum.</p>
<h2>Where can you buy coffee?</h2>
<p><b>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</b> Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
If the "ransom" part of this question is too difficult to achieve, it would be find to bold only the 1st second or 3rd sentences between H2s.
to the first period or question mark is a sentence, and from the first to the second period is also a sentence. BUT it can only bold ONE of them.
– Yerain Sep 22 '22 at 12:57