Skip to content

Instantly share code, notes, and snippets.

@LinzardMac
Last active August 25, 2015 21:54
Show Gist options
  • Save LinzardMac/30a7fd8a3d5b0dd3340d to your computer and use it in GitHub Desktop.
Save LinzardMac/30a7fd8a3d5b0dd3340d to your computer and use it in GitHub Desktop.
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
if ( 'post' == get_post_type() && is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( 6, 1, $content );
}
}
function prefix_insert_after_paragraph( $zone, $paragraph_id, $content ) {
$contents = explode("</p>", $content);
$p_count = 1;
foreach($contents as $content)
{
$output .= $content;
if($p_count == $paragraph_id)
{
$output .= banner_zone($zone);
}
$output .= "</p>";
$p_count++;
}
return $output;
}
function banner_zone($id){
oiopub_banner_zone($id, 'center');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment