I use a code like the one shown below to insert ads after the first paragraph.
The problem is that this code requires the content to be displayed within paragraph tags and I would like to use this code to insert a DIV.
When I simply replace the tags with div tags the code no longer works.
How do I remove the paragraph tags from the code while allowing the code to remain functional?
<?php
$paragraphAfter= 1; //display after the first paragraph
$content = apply_filters('the_content', get_the_content());
$content = explode("<p>", $content);
for ($i = 0; $i <count($content); $i++ ) {
if ($i == $paragraphAfter) { ?>
CONTENT GOES HERE
<?php }
echo $content[$i] . "</p>";
} ?>
<div>
inside a<p>
tag? – s_ha_dum Jun 24 '13 at 15:07