How to easily add AdSense to your WordPress posts

Manually adding AdSense to WordPress posts is a relatively simple task that can be accomplished within just a couple of minutes. In this tutorial, we cover the process of adding the code to the singlepost.php. This will allow us to display advertisements on every post only when the post is individually viewed. There are many places within the singlepost.php to add the code, for the sake of simplicity, we are going to cover the hotspot.

Adding Google Ads to WordPress Posts :

  1. Login to your AdSense account and create a new AdSense code. I used a 336X280 format
  2. Login to your WordPress Administration panel
  3. From the navmenu click Appearance > Editor
  4. From the Theme Files section, select Single Post (single.php)
  5. Within the theme editor window, scroll down to where it says <div class="entrytext">
  6. Directly below <div class="entrytext"> add your AdSense code from step 1
  7. Click the Update file button and go view your site!

(Optional) You can surround the code with <div></div> tags. This will allow us to position the advertisment where we want it. See the example code below.

Left side placement example:

<div style="float:left; padding-top:20px; padding-right:10px;"><script type="text/javascript"><!--
google_ad_client = "pub-1234567890";
google_ad_slot = "1234567890";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>

If you want the Google ad to float right, change float:left to float:right. If you don't want to position the code left or right just surround your code with the <div></div> tags