Created
March 25, 2015 11:58
-
-
Save mcgregormedia/0ac3c80cd00f294e10d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$required_paragraphs = 3; | |
$content = apply_filters( 'the_content', $post->post_content ); | |
if( substr_count ( $content, '<p>' ) > $required_paragraphs ){ | |
$contents = explode( "</p>", $content ); | |
$paragraphs = 1; | |
foreach( $contents as $content ){ | |
echo $content; | |
if( $paragraphs == $required_paragraphs ){ | |
/* Advert code here */ | |
} | |
echo "</p>"; | |
$paragraphs++; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment