Add AdSense to Your Wordpress Blog
As you can see I use the AdSense program on this the More Earnings Blog. This post will explain how other Wordpress users can achieve a similar use of AdSense on their Wordpress blogs.
If you are feeling lazy check out the WordPress Themes category on this site, you’ll find WordPress themes with AdSense already added. Popular themes like Blix, Connections and Almost Spring all with AdSense added.
Wordpress has a quite easy to use template system, trust me I’ve tried many popular blog CMS’s and Wordpress is by far the easiest.
There’s two ways to edit a template, via the built in template editor or in a HTML editor. I use a HTML editor (just a basic text editor not unlike Notepad) for major template work and the built in editor for small changes.
I’ll only deal with the built in editor for this post since explaining FTP etc… is too much for one post.
So log in to your blogs Dashboard and click the Presentation link, select the blog template you wish to edit followed by the Theme Editor link.
You should see a page like this-

You can see from WordPress post pages like AdSense Revenue there are multiple Google AdSense Ads on the page. You should be aware at this point you can only use three ad blocks per page (you might find Make the most of your ad units helpful). This makes adding the AdSense code a little trickier than if you could add unlimited ad blocks, but with a little thought it’s possible.
So three AdSense for content ad blocks is what we are aiming for, to achieve this I added one Wide Skyscraper (160 x 600) ad block to the side menu, one Square (250 x 250) ad block and one Banner (468 x 60) ad block to the content to Wordpress posts.
Adding AdSense Ads to the Menu
Using the Wordpress Theme Editor open the file Sidebar (sidebar.php). The actual code will vary depending upon which template you are using, this is for the Wordpress theme Almost Spring, but will be relevant for most themes.
You will see code like this-
<div id=”sidebar”>
<ul>
< ?php wp_list_pages(’title_li=<h2>’ . __(’Pages’) . ” ); ?>
<li>
</h2></h2><h2>< ?php _e(’Archives’); ?></h2>
<ul>
< ?php wp_get_archives(’type=monthly’); ?>
</ul>
The simplest way to add your AdSense block is to insert it near the top-
<div id=”sidebar”>
<script type=”text/javascript”><!–
google_ad_client = “pub-****************″;
google_ad_width = 160;
google_ad_height = 600;
google_ad_format = “160×600_as”;
google_ad_type = “text_image”;
google_ad_channel =””;
google_color_border = [”E8E7D0″];
google_color_bg = “FFFFFF”;
google_color_link = [”B96F17″];
google_color_url = [”B96F17″];
google_color_text = “000000″;
//–></script>
<script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script><ul>
< ?php wp_list_pages(’title_li=<h2>’ . __(’Pages’) . ” ); ?>
<li>
</h2></h2><h2>< ?php _e(’Archives’); ?></h2>
<ul>
< ?php wp_get_archives(’type=monthly’); ?>
</ul>
Note: You’ll need to replace my ****************** with your code .
This would put the AdSense ad right at the top of the menu. You can see from this blog it’s possible to put the ad block lower on the menu, I have it between Categories and Archives. So feel free to experiment with it’s placement.
You may find wrapping the AdSense code in a div helpful since you can then add padding etc…-
<div style=”padding-left:5px; padding-right:5px; padding-bottom:5px; padding-top:5px; “>
<script type=”text/javascript”><!–
google_ad_client = “pub-****************″;
google_ad_width = 160;
google_ad_height = 600;
google_ad_format = “160×600_as”;
google_ad_type = “text_image”;
google_ad_channel =””;
google_color_border = [”E8E7D0″];
google_color_bg = “FFFFFF”;
google_color_link = [”B96F17″];
google_color_url = [”B96F17″];
google_color_text = “000000″;
//–></script>
<script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>
</div>
You can then edit the div’s style to match your sites positioning by adding more or less padding, the above code gives 5 pixel of padding around the entire AdSense block, padding is very useful when your Ad block doesn’t quite line in with the rest of the menu (try 10 for all values to see what it looks like).
When complete click the Update File button within the Theme Editor and all your pages will now have a Wide Skyscraper (160×600) AdSense ad on the side menu.
If you find the file won’t save (if you see the message “If this file were writable you could edit it.” where the Update File button should be) you will have to change the files write permission (needs to be 666). To do this access your site via FTP and navigate to /wp-content/themes/YOUR-THEME/ now select all files in the directory and change permission to 666 (it will probably be 644). You can find more info about this at Wordpress support forums.
Adding AdSense Ads Within the Content of Posts
Now we come to the trick part, we want individual post pages (like this one) to have an AdSense ad within the content (will result in more clicks = more revenue), but we can’t have 10 AdSense ads on every archive and similar pages.
Fortunately Wordpress templates have a file called Single Post (single.php) load it into the theme editor and you should see something like this-
<div class=”postentry”>
<?php the_content(__(’Read the rest of this entry »’)); ?>
<?php wp_link_pages(); ?>
</div>
Add the AdSense code for a Square (250 x 250) ad block as follows (note the div with the float right styling, this is important).
<div class=”postentry”>
<div style=”float:right; padding-left:5px;”>
<script type=”text/javascript”><!–
google_ad_client = “pub-****************″;
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = “250×250_as”;
google_ad_type = “text_image”;
google_ad_channel =””;
google_color_border = “E8E7D0″;
google_color_bg = “FFFFFF”;
google_color_link = “B96F17″;
google_color_url = “B96F17″;
google_color_text = “000000″;
//–></script>
<script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>
</div><?php the_content(__(’Read the rest of this entry »’)); ?>
<?php wp_link_pages(); ?>
</div>
When the file is updated all your Wordpress single post pages will have a square AdSense ad floating to the right of the posts content, but the same posts on archive and similar pages will have no ad block. This ad will most likely generate most income because it’s in a hot click area (see AdSense Heat Map).
That leaves the third and final AdSense ad block which I’ve added just above the comment area of the blog page. To add this we again edit Single Post (single.php) using the Wordpress built in theme editor.
<div class=”postentry”>
<?php the_content(__(’Read the rest of this entry »’)); ?>
<?php wp_link_pages(); ?>
</div><p class=”postfeedback”>
Add the AdSense code for a Banner (468 x 60) ad block as follows.
<div class=”postentry”>
<?php the_content(__(’Read the rest of this entry »’)); ?>
<?php wp_link_pages(); ?>
</div><script type=”text/javascript”><!–
google_ad_client = “pub-****************″;
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = “468×60_as”;
google_ad_type = “text_image”;
google_ad_channel =””;
google_color_border = “E8E7D0″;
google_color_bg = “FFFFFF”;
google_color_link = “B96F17″;
google_color_url = “B96F17″;
google_color_text = “000000″;
//–></script>
<script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script><p class=”postfeedback”>
With the Wordpress theme I use (Almost Spring) this ad block just fits. If you find there isn’t enough room try a smaller width ad. You might have to add a div with center text align to make it look right.
This last ad block will probably be low click thru because of it’s location.
And there you have it three Google AdSense ad blocks added to a WordPress blog. If you use my technique and want to say thanks link to this page (or the home page) from your blog. Also feel free to add a comment below, love to see others using my ideas.


Leave a Reply
You must be logged in to post a comment.