I'm looking for a clean way of filtering the_content to add a piece of code before each H1 tag present in it. In fact, I have a long privacy policy text and I want to add a back to the top link before each paragraph. Of course, I could easily add these in the content editor but I don't want my customer to be able to remove it accidentally.
So I have something like :
<h1>BLA BLA BLA</h1>
<p>A very interesting piece of text here...<p>
<h1>BLA BLA BLA</h1>
<p>A very interesting piece of text here...<p>
<h1>BLA BLA BLA</h1>
<p>A very interesting piece of text here...<p>
and I want to filter it to get :
<a href="#">Back to the top</a>
<h1>BLA BLA BLA</h1>
<p>A very interesting piece of text here...<p>
<a href="#">Back to the top</a>
<h1>BLA BLA BLA</h1>
<p>A very interesting piece of text here...<p>
<a href="#">Back to the top</a>
<h1>BLA BLA BLA</h1>
<p>A very interesting piece of text here...<p>
Thanks in advance for your time.
Cheers,
J.