How To Add AdSense Ads To A WordPress Blog
Placing Google AdSense on your WordPress can be accomplished in a variety of ways. Because of the big blogging rush happening right now many people are building blogs to make money blogging. And the first thing they want to do is to put Google AdSense on their blog. Here is a WordPress guide that gives you different options for integrating Ads into your WordPress blog.
The first and obvious area to place your ads is on the sidebar. This has never been easier with the use of text widgets. To place AdSense on your sidebar read this: Working With WordPress Text Widgets
Then there are plugins to place AdSense within your blog posts. The most popular one, and the one I include when I install WordPress is AdSense Deluxe. Read how to Install And Configure AdSense Deluxe WordPress Plugin.
To add AdSense or other ads directly into your WordPress theme you must place the ad code directly into a few of the themes files depending on where you want the ads to show.
To edit your themes files from within the WordPress dashboard the file permissions must be set to writable on your hosting account, CHMOD them to 666 or 777. Then from the dashboard go to Presentation, Theme Editor. Make sure you have a backup of the file you are editing if you are not comfortable messing around with the code in there.
If you want the ads to show on the top of the main page above the title of the first post you need to place them in the Main Index or index.php file. Look for and open index.php on the right side of the theme editor. Look for this code near the top and place your ads like shown below:
Put Your Ad Code Here
<?php if (have_posts()) : //Are there any posts? ?>
You can do the same steps above on the Single Post (single.php), Archives (archive.php) and the Page Template (page.php).
As you start looking at the different files, you can start to see different places to place your ads, or anything for that matter within your blogs theme. For example to place the ad code on the bottom of each post Open the Single Post template (single.php). Place the ad code in the area show just below the post:
<?php if(have_posts()): ?><?php while(have_posts()):the_post(); ?>
<div class=”post”>
Place Ad Code Here
One note of caution! Please copy, paste and save into a text file on your computer all the text in any file you are attempting to edit before you make any changes!
If you liked this post, feel free to leave a comment that is relevant to the post or subscribe to the feed and get future articles delivered to your feed reader.
Sorry but due to the spamming of a few all comments are moderated and will appear when approved and all drive-by comments will be deleted!












Comments
If you want the ads to show on the top of the main page above the title of the first post you need to place them in the Main Index or index.php file. Look for and open index.php on the right side of the theme editor. Look for this code near the top and place your ads like shown below:
Title Of Site
Reply
“To edit your themes files from within the WordPress dashboard the file permissions must be set to writable on your hosting account, CHMOD them to 666 or 777.”
For security sake, I would suggest everyone that does it this way to change back the permissions to 666 once you’re done with editing.
Reply
is there a way of adding the adsense block just below the first post only, instead of below every post?
Reply
Yes you can place an AdSense block just about anywhere. To add it to the bottom of the first post on the main blog page:
Open the Main Index Template (index.php) and place the AdSense code under the block of code that starts like this:
That will put it under the post before the comment area, if it is showing. You can experiment with different places in the index.php file
Reply
Adding the adsense codes is easy, but optimizing the layout is another story.
Reply
Hi information you provided are quite helpful ….but i want to know how to add adsense code in the sidebar??
please help
Reply
debashish, you just need to place the AdSense code into a text widget if your theme is setup for them.
See this post:
Working With WordPress Text Widgets
Reply
Aww, I’ve been searching through so many tutorials but I don’t actually have a single.php file in my theme folder! How is that possible!? I’d really like to put ads below every post, and have those ads viewable only when the reader clicks on that post.. Help! o.O
Reply
I V Y O L O G Y , I can’t answer your question without seeing your theme’s files.
Reply
Wow, super fast response Jeff! But it’s ok, I worked out how to do it the easy way – download a plugin
Thanks for your help!
Reply
Jeff, by your experience, where’s the best spot to place adsense ads?
Reply
I don’t actually track AdSense placement, and admit I am not an AdSense placement expert, but my first choice would be at the bottom of the post for a well written blog. So the reader has somewhere to click to after they are done reading.
Reply
The information you provided are quite helpful.Thanks
Windows Vista Help and Support
Reply
What does everyone think about “adsense blindness”? Where browsers ignore what looks like an adsense ad because they are too familiar with the format?
I believe Yahoo will make big leaps forward with paid ads soon. They are a lot easier to slip in discretely!!
Reply
I agree, Yahoo ads are a lot easier to individually style
Reply
But the return you get on Yahoo ads is nowhere near that of yahoo. Dont forget theyre easy to hide for a reason!
Reply
[...] How To Add Adsense Ads To A Wordpress Blog [...]
I have 6 templates and none of them contain a single.php file. Is there an alternate file it should go in since single.php is so uncommon.
Reply
Colin, some themes use the page or index file for single posts.
Reply
yes, as always, Yahoo and other search engine ads are always easier to add than Google but as always, Google ads provide the most revenue!
Reply
Thanks for the info…I updated to latest version of Wordpress and forgot I had ads inserted.
Reply
Great post… I have always had a hard time getting my Adsense ads to look good or look enticing for people to click on. I keep trying new looks or layouts to find the best option. I wonder if there is data out there for the best Adsense layout for conversion on a blog? Thanks,
DAN
Reply
Hey, thanks for all the links. I think I’ll go with the Text Widgets especially because you said it was very simple. Adding AdSense directly into the WP theme sounds a bit more complicated, although i think visually it might look better since you have more freedom with its location.
-Alex Martin
Reply
I’ve tried numerous suggestions, forums and sites and the only thing I get after adding the Adsense code in the index.php file is
script type=”text/javascript”>
I’ve tried in in the single.php as well ans get the same results. Any suggestions?
Reply
Jeff Replied:
June 7th, 2009 at 9:48 pm
Tom all I have ever done is paste the code in right from AdSense.
Reply
I did as you suggested and it works great. So much for hidden codes, special instructions and loops. I worked for hours yesterday following the instructions I had been given with zero results. I did what you said and in five minutes I was good to go. Thanks for the tip.
Reply
I heard earlier that Wordpress blog doesn’t let you put adds on your blog. But it’s great to hear again that bloggers can make money through Wordpress blogs again. Thanks for letting me know,I will be starting the one soon.
Reply
Jeff Replied:
June 14th, 2009 at 7:49 am
There is a difference between a self-hosted WordPress blog and a free blog on wordpress.com. No you can’t put AdSense on a wordpress.com blog but you can do whatever you want on a self-hosted WordPress powered blog on your own domain as this is referring to.
Reply
Leave a comment
Drive-By comments will be deleted! Like "Thanks for sharing", "Nice post", or any other text that doesn't contribute to the discussion. If you ask a very specific question about your particular WordPress theme's code, it will probably be deleted. I can fix your WordPress site but for a price. If you ask a question like "Why don't my blog work right", it will be deleted. If you ask a question about your WordPress site without a leaving a link to it, it will be deleted. The point is to ask questions and or comment on the the actual content of the post, and to please use some common sense. All comments are moderated. Thank you.