I need to loop through each paragraph in the_content and add an ID to each paragraph with an incremental value.

    for ($i = 0; $i <count($content); $i++) {
        return str_replace( "<p>", "<p data-section-id=" . $i . ">", $content );
add_filter( 'the_content', 'incrementparagraphs', 10, 1 );

Read more here: Add Incrementing ID to each paragraph in the_content


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , ,

Wordpress related questions and answers: