[ad_1]
Hi
Is there any way to add a filter to the\_content() to wrap every H2 title with all the content after it (until the next H2) in a section with an id made from the H2.
So changing this:
<h2>Title 1</h2>
<p>Some text</p>
<h2>Title 2</h2>
<p>Some text</p>
to this:
<section id=”title-1″>
<h2>Title 1</h2>
<p>Some text</p>
</section>
<section id=”title-2″>
<h2>Title 2</h2>
<p>Some text</p>
</section>
Hope it’s clear
Thanks
[ad_2]
“`
add_filter(‘the_content’, function($content){
// Your code here
return $content;
});
“`