Insert After Second Paragraph Without Tag?

I need to stress that I think this is going to be very unstable and you may not always get the results you want, but in simple cases this should work.

$content = apply_filters('the_content', get_the_content());
$content = explode("</p>", $content, 2);
// var_dump($content); // debug
echo $content[0].'</p>';
echo '<div>Extra Content</div>';
if (!empty($content[1])) {
  echo $content[1];
}

Leave a Comment

error code: 523