Add Google Adsense to your WordPress Post

1

After having nothing but problems with WordPress Plugins that run Google Adsense I decided to just do it myself.

Its not hard. Go to your single.php either via FTP or in your editor and find this line of code: <?php the_content(‘ ‘); ?>

Right before that code put this:

<div id=”google-ad”>
<script type=”text/javascript”><!–
google_ad_client = “pub-your code here”;
google_ad_slot = “adslot code here”;
google_ad_width = 300;
google_ad_height = 250;
//–>
</script>
<script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>
</div>

Then, go to your style.css, or whatever your core css file is and put this into it:

#google-ad {
float:right;
padding-left:5px;
width:300px;
height:250px;
}

There is a caveat: this puts the ad code to the right of your post and has your post wrap around it. You could place the code where ever you want, but this is the most valuable area. If you want to change the position play around with your CSS. Enjoy.

1 COMMENT

LEAVE A REPLY