Last active
August 25, 2015 21:54
-
-
Save LinzardMac/30a7fd8a3d5b0dd3340d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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