Hi there,
you would need to filter the_content – try this PHP Snippet:
add_filter( 'the_content', 'db_suffix_first_h2_custom_html' );
function db_suffix_first_h2_custom_html( $content ) {
$html = '<div>My custom HTML after first H2</div>';
if ( is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( $html, 2, $content );
}
return $content;
}
function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {
$closing_p = '</h2>';
$paragraphs = explode( $closing_p, $content );
if ($paragraphs) {
$paragraphs[0] = $paragraphs[0].'</h2>'.$insertion;
}
return implode( '', $paragraphs );
}
Update the $html = '<div>My custom HTML after first H2</div>'; to include your HTML.