Add AdSense to a Wordpress Blog
Posted by SEO Dave on July 28th, 2006 at 07:36pm
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.
Update: I now sell WordPress Themes with AdSense/SEO at Google AdSense Themes. These include a file designed for novice WordPress users to set options like ad colour, ad unit sizes, channels, border corners etc… though if your a complete technophobe (like my wife) adding your google_ad_client (the pub-number) is all that’s needed (if you can copy and paste one small line of text you can setup my themes) to have your site have the same level of SEO/AdSense ads you see on my sites like these-
Adventure Travel Vacations : uses Talian WordPress Theme (very popular theme).
The Big Feature : youngest sons site, uses Naruto Strikes Back WordPress Theme (converted that theme for my son :-)).
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, (in WordPress 2.5 click the Design 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-8325072546567078″;
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 google_ad_client with your code otherwise I’ll be paid for all your AdSense clicks!
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-8325072546567078″;
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 tricky 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-8325072546567078″;
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-8325072546567078″;
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.
Popularity: 7%
Under Google AdSense+ WordPress Themes
Related posts to Add AdSense to a Wordpress Blog
WordPress Theme Kubrick with Google AdSense
Kubrick is my fifth in a series of AdSense converted WordPress theme. Kubrick Theme with AdSense Installation Instructions Download the kubrick-adsense-02.zip file below Download Kubrick with AdSense WordPress...
WordPress Theme Ocadia with Google AdSense
Ocadia is my fourth in a series of AdSense converted WordPress theme. Like the other themes I converted, Blix, Connections and Almost Spring, it uses...
WordPress Theme Almost Spring with Google AdSense
Almost Spring is my third AdSense converted WordPress theme. Like the first two themes I converted, Blix and Connections, it uses 3 blended Google AdSense...
WordPress Theme Connections with Google AdSense
Connections is my second AdSense converted WordPress theme. Like the first theme I converted, Blix, it uses 3 blended Google AdSense units per page in...
WordPress Theme Blix with Google AdSense
I now sell AdSense ready WordPress 2.3 Themes and Blogspot Templates at Google AdSense SEO Themes and Templates. Check the WordPress ones under the WordPress Themes...

24 Comments for Add AdSense to a Wordpress Blog
1. perry | August 12th, 2006 at 12:12 am
your blog entry was very helpful to me, but when i tried to add the 250×250 block to my singlepost.php file, it seems to have worked, but it left my header and my footer scooted over to the left of the actual post. It doesnt look right. Is there an easy fix to this? BTWL I’m using the “classic” wordpress theme I think. (I’m totally new to this).
2. SEO Dave | August 12th, 2006 at 11:22 am
Hey Perry,
Not tried adding AdSense to the classic theme (there is a theme called classic), I’ve got it on the server. Had a look and didn’t see a post page for that theme though, which would mean it uses the default singlepost page.
Or did you mean the default theme?
That has a singlepost template page and should work the same as the template I’m using (looks similar).
If you make another comment add your URL I’ll take a look and then when I’m sure which theme you mean try it to see what happens (only takes a minute to try).
Oh and sorry about your comment getting filtered, the comments filters are broke right now do to excessive comment spam (broke the database a while back), so everything is filtered!
David
3. AdSense now working | May 14th, 2007 at 8:24 am
very helpful article for me to add adsense code to my blog
4. Pufone | May 20th, 2007 at 9:23 am
Hello David.
Your tutorial is really good, however it’s much easyer to use a plugin like AdSense Deluxe or Mutube Adsense Manager. I have a tutorial on how to add AdSense to WordPress blogs. The best thing about plugins is easy management of ads: from colours to shapes and location. Allso theme tweaking requires lots of time and when you decide to change it, you have to start all over
5. SEO Dave | May 20th, 2007 at 11:16 am
Hi Pufone,
It is much easier to use a plugin, however I’ve not seen a plugin yet that puts the ads in the right place, for example Mutube Adsense Manager appears to only ad ads to the sidebar which will see a low CTR!
So for me adding them manually is the best (only) way.
If you look through http://www.morearnings.com/category/wordpress-themes/ you’ll find some popular WordPress themes that I’ve added AdSense to and they are free to download.
6. Kymberlyn | May 29th, 2007 at 9:46 am
Dave thank you so very much for this post. I have been trying to ad adsense to my blog for months now without success. It’s fair to say I am not very “blogwise”. Using your info I have managed to add it to my sidebar but I am still not seeing in my posts. Can you tell me what I am doing wrong? Thank you in advance. Your blog(s) are enormously helpful
7. Subodh | July 26th, 2007 at 2:25 am
I am trying to ads within the content of posts but theme which I am using doesn’t having Single Post (single.php) . So can you please help.
8. Jenny Dating | August 3rd, 2007 at 8:28 pm
Hello,
I installed your theme and it worked great.
big thanks.
I do have one question: how do I add adsense channel to the code so I know how much I earn from my blog?
Thanks.
9. Jiun | September 2nd, 2007 at 5:21 am
Hi Dave, Wonder if you could help me out here. The theme I’m using doesn’t have a single.php so how do I add the code to my post? Thanks.
10. SEO Dave | September 2nd, 2007 at 12:45 pm
Look though the template pages for this-
div class=”postentry”
Then using trial and error post the AdSense code, if it’s the wrong template page remove it and try the next one. Eventually you’ll find the right page
David
11. Cruelty-free shopping | November 4th, 2007 at 4:33 am
Dave, Thanks for this post. I had installed connections and was looking for ways to add adsense. Your adsense-enabled connections theme was like THE perfect match.
Is there a way I can make this theme widget-aware?
I do seo as well, though not nearly accomplished as you are. I read your blog regularly as well. I have placed links to your sites at:
http://veggieplaza.com/veggieblog/?page_id=4
http://www.olympictabletennis.com/index.php?option=com_weblinks&catid=23&Itemid=23
Most of my sites are PR 1 or 2 as of now so I know that you are not really gaining too much from me but I will appreciate it a lot.
Thanks again! Look forward to your reply and staying in touch.
12. AdSense Rocks | November 7th, 2007 at 2:31 pm
Thanks for this tutorial - I was able to add my adsense block in a matter on minutes. Hopefully I’ll see a great CTR!
13. How to Wrap Text Around A&hellip | November 8th, 2007 at 1:57 pm
[…] the instructions on wrapping text around Adsense, go here Add AdSense to a Wordpress Blog and look for this text: Add the AdSense code for a Square (250 x 250) ad block as follows (note the […]
14. Rajeev Edmonds | November 21st, 2007 at 3:51 pm
I personally use Adsense Deluxe plugin for Wordpress in one of my blogs and it makes my life easier in integrating my Adsense Code in the pages.
15. Free Blog | November 21st, 2007 at 5:01 pm
How to add adsense and meta tags to free wordpress blog?
Nothing to do with the free blog I guess
Its nothing on the point of advertising and earnings
16. Nadia | November 24th, 2007 at 10:03 pm
This info is very useful, thanks.
Can you give an example where to put google’s code to get skyscraper between categories and archive like you have?
Thank you.
17. wegeer | December 11th, 2007 at 1:15 pm
There is a plugin for inserting adsense automatically into blog posts .It is called “All in One Adsense and YPN” plugin:
http://www.linewbie.com/wordpress-plugins/all-in-one-adsense-and-ypn
18. AdSense works | December 19th, 2007 at 10:06 am
wow mate
this was what i was luking for
nice nd good xplanation how to add adsense to my blog
have tried adsense plugin , but coudnt make it working .
this worked in first shot
thanks
where is u r buy me a coffee , lunch button
19. SusanneUK | January 17th, 2008 at 11:26 am
Thanks so much for this very well laid out assistance, so easy to understand and implement.
I did get one odd thing though, hope you can help..
I put the adsense into the single post thing.. and I made sure the “Float Right” part was there and double checked myself several times, but my adsense ads appear above the content of my post and to the left..
Not sure what to do..
Hope you can help but again thanks so much for this.
Sue
20. SusanneUK | January 17th, 2008 at 3:58 pm
Hi again
Just wanted to let you know I sorted out the problem, the font for the ” was wrong in my copy.. changed that and now it works..
Thanks very much
Sue
21. BallparkBob | January 21st, 2008 at 7:04 pm
I am using the Digg 3 Column blog from WordPress. When I click on “Presentation”, I don’t see a link that says “Theme Editor Link”. Perhaps things have changed since you first made this post or I selected a blog theme that does not support this? Any advice is greatly appreciated.
22. DeSTInY | March 11th, 2008 at 3:37 pm
Google Adsense is the flagship of contextual advertising! Really the best webmaster program for earning money!
23. sheetal | April 11th, 2008 at 7:36 pm
Hi Dave,
I installed your connection adsense,and absolutely loved it. But the sidebar was a problem, so I changed to dig3, which doesn’t have inbulit adsense. This tutorial helped me a lot to insert the adsense in the post. Thanks
24. SEO Dave | April 19th, 2008 at 10:43 am
Hi BallparkBob,
Sorry for taking so long to respond (so many blogs to moderate!).
Have updated this page to include instructions for adding AdSense to WordPress 2.5.
David
Leave a Comment for Add AdSense to a Wordpress Blog