我使用如下代码在第一段后插入广告。
问题是,此代码要求在段落标记中显示内容,我想使用此代码插入DIV。
当我简单地用DIV标记替换标记时,代码不再工作。
如何从代码中删除段落标记,同时保持代码的功能?
<?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>";
} ?>