Last active
August 29, 2015 14:26
-
-
Save vijujohns/bd843f41fc3e1f5df73d to your computer and use it in GitHub Desktop.
Automatically insert Google Adsense ad to the top left or right of each post content http://www.wppicker.com/how-to-insert-ads-to-top-left-right-of-post-content-without-plugins/
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
//Automatically Insert Google Adsense ads to the top left or right of each post content. | |
add_filter( 'the_content', 'wpp_insert_ads_to_content' ); | |
function wpp_insert_ads_to_content( $content ) { | |
$ad_code_wrapper_start = '<div style=”display:block;float:right;margin: 0px 0px 0px 10px;”>'; | |
$ad_code = ' Copy and Paste Ad sense code here. Do not remove the starting and ending single quotes '; | |
$ad_code_wrapper_end = '</div>'; | |
if ( is_single() && ! is_admin() ) { | |
$content = $ad_code_wrapper_start.$ad_code.$ad_code_wrapper_end.$content; | |
} | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment