Skip to content

Instantly share code, notes, and snippets.

@blurain82
Forked from theukedge/gist:6745757
Created January 19, 2017 12:28
Show Gist options
  • Save blurain82/9d59152315ae0a23bdbf65459f180c03 to your computer and use it in GitHub Desktop.
Save blurain82/9d59152315ae0a23bdbf65459f180c03 to your computer and use it in GitHub Desktop.
<?php
$show_after_p = 2;
$content = apply_filters('the_content', $post->post_content);
if(substr_count($content, '<p>') > $show_after_p)
{
$contents = explode("</p>", $content);
$p_count = 1;
foreach($contents as $content)
{
echo $content;
if($p_count == $show_after_p)
{
?>
YOUR AD CODE GOES HERE
<?php
}
echo "</p>";
$p_count++;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment