我正在使用此代码在wordpress的文本段落之后添加广告
add_filter('the_content', 'wpse_ad_content_two');
function wpse_ad_content_two($content)
{
if (!is_single()) return $content;
$paragraphAfter = 10; //Enter number of paragraphs to display ad after.
$content = explode("</p>", $content);
$new_content = '';
for ($i = 0; $i < count($content); $i++) {
if ($i == $paragraphAfter) {
$new_content.= '[irp]';
}
$new_content.= $content[$i] . "</p>";
}
return $new_content;
}
但是我对表有问题。当我有<table><p></p></table>
时,我希望避免插入广告。我该怎么办?