Skip to content

Instantly share code, notes, and snippets.

@adapicom
Last active December 19, 2015 01:48
Show Gist options
  • Save adapicom/5878191 to your computer and use it in GitHub Desktop.
Save adapicom/5878191 to your computer and use it in GitHub Desktop.
Ad Inside Wordpress Content
<?php
$paragraphAfter= 7; //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) { ?>
<!-- Place Ad Content Here -->
<?php }
echo $content[$i] . "</p>";
} ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment