AskCarl: How to Add AdSense to a WordPress blog? In Various Situations
John e-mailed me a while ago asking me on how did I place AdSense to my WordPress blog. Too bad John didn’t have a site to show me. Anyway I’ll post here my tutorial on how to add Adsense into a WP blog.
Adding AdSense After Post Titles
Let’s go on the basics first. For example: You want to add a 336 x 280 AdSense block below you post title. Open your index.php then look for the part that looks like this:

And if you want to wrap that block, like most blogs do. Add a div into the Adsense code that may look like the one below:

Just adjust the margin that suits your blog design best and of course you could also change the float to “left” or “right”.
Some have situations adding an AdSense unit on their first post but not on the second (I used to do this before ) to do that, open your index.php then look for something like this:

We’re not done yet! Look for this on your index.php:

Then place this on the part that says “****Your Adsense Code goes here****“

See, piece of cake
Special thanks to tamba2 for the code.
Adding AdSense After Every Entry
If you want to place an Adsense block every after your entry ( Like what I have — for now
) You will need to open your index.php then look for this part:

And if you want, you can also add a center tag to make it look more decent.
Adding AdSense to Single Posts
If you want AdSense only in your single posts. Open your single.php then look for something like this:

Actually it’s the same as Adding AdSense After Post Titles (Above)
Adding AdSense Before your Header
Lastly, if you want to add an AdSense unit before your header (Like b5media blogs, etc.)
Open your header.php and look for a code like the one below:

Easy!
But still if it’s that hard for you to integrate AdSense units to your WordPress blog, there’s always a plugins to the help.
If you have any comments or want to add or suggest something. Don’t be shy to leave me a comment
Have any questions? Don’t want to waste time searching Google? just drop me a mail and I’ll try my best to answer your question!

Just enter your first name and valid email address below, then click the



Hi Carl.
I am just set up one wordpress at my host. I open index.php it ’s empty inside…Where I can looking for index.php…I am newbie..Thank
Peter
Carl, you are cool.. lol. I use blogger.
Thanks Carl….just what I was searching for! I couldn’t believe when I scrolled down and found out you are 13 or 14…God Bless You! You will surely succeed in life! Thanks again!
I have created a google blogger but when I try to add the adsense code into my blogger, it gave me an error message. I try it many time but I just get the same error message. HELP! I’m new with this internet thing and am in need of someone who know what they’re doing. It would be nice to have my blogger up and running. Can you help me? Thanks
Hi Carl,
I’m trying to put an adsense vertical widget in my sidebar. I’ve copied the code into a ‘text’ unit in my sidebar but it’s not showing….sob.
What should I do?