Last active
December 15, 2015 14:49
-
-
Save braddalton/5277191 to your computer and use it in GitHub Desktop.
Change the 007 to your category i.d
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
/** | |
* @author Brad Dalton - WP Sites | |
* | |
* @link http://wpsites.net/web-design/ads-specific-paragraph-single-posts/ | |
*/ | |
add_filter( 'the_content', 'wpsites_adsense_middle_content' ); | |
function wpsites_adsense_middle_content( $content ) { | |
if( is_single() && in_category ('7') ) | |
return $content; | |
$paragraphAfter = 1; //Enter paragraph number | |
$content = explode ( "</p>", $content ); | |
$new_content = ''; | |
for ( $i = 0; $i < count ( $content ); $i ++ ) { | |
if ( $i == $paragraphAfter ) { | |
$new_content .= '<div style="width: 600px; height: 100px; padding: 5px 5px 5px 0; margin-right: 0;">'; | |
$new_content .= 'Paste Adsense Code Here'; | |
$new_content .= '</div>'; | |
} | |
$new_content .= $content[$i] . "</p>"; | |
} | |
return $new_content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment