How To Insert Adsense Into WordPress Post
Have you ever wanted to insert your adsense code right into your wordpress post but wasn’t sure how to do it? You’re in luck! I’m going to show you exactly how to do this. This won’t take but a second, it’s a really quick fix.
Log in to your wordpress admin.
Navigate to your theme editor. How to get there depends on the version of wordpress you are using. If you are currently up to date, it will be “Design >> Theme Editor”
Once there, click on “Single Post (single.php) on the right hand column of the editor page.
Copy and paste
<table border=”0″ width=”302″ id=”table1″ cellspacing=”3″ cellpadding=”3″ height=”252″ align=”left”>
<tr>
<td>
YOUR ADSENSE CODE GOES HERE
</td>
</tr>
</table>
right above
<?php the_content(‘Read the rest of this entry »’); ?>
Your themes code may vary but it will be directly above the “the_content” call, you may have category exclusions or different text for reading the rest of the post but regardless, that’s where it goes.
Now your posts will look like…
The code above is set to use the 300×250 square adsense ad. You can use a different size ad by changing the dimensions on the table. Try and make your table bigger each direction by a couple of pixels to allow for a little spacing and so that there are no browser display problems.
You’re not limited to adsense. Post the code for any banner or text there that you like.
If you have any trouble, let me know below and I’ll try to help out.
There ya go!
Take Care,
Gail
![]() |



I’ve tried this code on a theme or two where it didn’t work. The fix for that is a little more complicated because it generally has something to do with your CSS. If you are comfortable with css, you can look in there for the problem (copy and paste entire css file into a text file first in case you have problems, you can just restore to default). I’ll post complete details in a different post for solving this in css.
Just one comment – since adsence seems to be another of google’s great tools – although we haven’t tried it on our blog yet, we have recorded a huge success with google adwords.
So thanks for this, we might look at this in future and then use your advice.
Thanks Gail. I’ve heard that your position for the Adsense is best. i.e. in the top left hand corner because it simulates a nav bar? Geoff D.
Geoff, Where you place your adsense ads kind of depends on what your page is about. Is that your primary source of revenue for the page? You may want that to be their first click or a second chance to make money should they not buy from you.
Here’s what Google says Where should I place Google ads on my pages?, and there are some free videos here Webmaster 101 Video Guide that pertain to Adsense Monetization.
There is another 3 ways that you can applied to insert Google Adsense code at the TOP LEFT & TOP RIGHTS of any blog post.
Based on my experienced and my research, this adsense ads unit in Top Left or Top Right corner have highest CTR. Adding this ads unit/s is very simple and only requires a bit code before and after your Google Adsense code.
I’ll try this out and see if this works for me. Thanks.
hi, i am completley confused as to how i am meant to put the code onto my wordpress blog webiste, please help!
Hi Adam,
Sorry you are having a problem. I will put together a short video when I get a chance. Meanwhile, where are you getting stuck at? I’ll try and help you.
Hi, This is a code that is supposed to place the 250 X 250 square ad in WordPress blog of Prosense Grey template. It doesn’t work. Maybe you can take a look and tell me what is wrong. Help.
Thanks for the great tip.
Can you tell me the best way to ad adsense to the page rather than the post?
I am using an Adsense ready blog at present but would like to change to another which is not adsense ready.
Hope you can advise.
Jack
Ken, if you are using the ProSense theme as I am here, just paste in < ?php include('adsense_singlepost_top_square.php') ?> directly above < \?php the_content('
Read the rest of this entry »‘); ?> (verify the adsense_singlepost_top_square.php is the 250×250 ad and replace if necessary being sure not to remove the div tag, < \div id="adsense_singlepost_top_square"\>. It should be but I can’t remember if the default for that was 250×250 or if I changed it.)
If you have any problems with it, let me know.
Edit: sorry, I had to add some \ so that it wouldn’t mess this post up.
Hi Jack. You can manually ad the code anywhere you like. Just go to your theme editor in your WP admin and paste the code where you would like it to display. single.php is the actual posts, page.php is for any pages you create. You can also edit archives.php, index.php and pretty much all of them.
Just copy everything from these files before you make any changes, that way if something doesn’t work, you can just paste back in to restore to original.
Pasting the code in single.php directly below < \div id="content"\> should place it at the top of the page like you see on this page. (edit: had to add \ to the div tag above because it messed the post up)
Pasting adsense code right above < ?php endwhile; else: ?> should place it under the post, like you see on this page.
Alternatively, you can create seperate text files for each ad size, upload them in your themes folder and include them in the page by pasting < ?php include('adsense_250x250.php') ?> into the template files instead of the entire code.
You might also find something useful in this post, http://www.wahguide.com/2008/12/technical/how-to-add-banner-rotation-to-your-wordpress-blog/
If you have any trouble, let me know and I’ll be happy to help any way I can.
I tried to send this and first I got an error message, and then when I tried to send it again, I got a duplicate send message. So will try again.
If I go in “Appearance” and then to “Editor” in WordPress, and go to the right side “theme files” I find “single post (single.php) but below that there are several adsense_singlepost_entries and the one that I sent you previously was from adsense_singlepost_top-square.php. Is that the one I replace?
I am still a little confused about the exact entry. If I take the entry from your web page and just put in my adsense code where you have it in Red, and I don’t add or delete anything else, Is that the exact entry that I need?
Thanks, Ken
Ken, I think you about got it!
If you’re using prosense,just paste…
<?php include(‘adsense_singlepost_top_square.php’) ?>
into single.php directly above <?php the_content(’Read the rest of this entry »’); ?>
Check adsense_singlepost_top_square.php and make sure that it looks like this…
<div id=”adsense_singlepost_top_square”>
YOUR ADSENSE CODE
</div>
Then check your stylesheet, style.css for…
#adsense_singlepost_top_square {
float: left;
margin-right: 10px;
}
If it’s not there, add it.
Let me know!
Ken, you can download the requested files here
http://wahguide.com/freebies/ProsenseAdsense.zip
If you still have trouble, reply with a link to download yours and I’ll look at your single.php and the adsense code page (I won’t publish the comment).
Hi Gail,
Are you able to insert the adsense code into some individual posts but not all? I can do it site wide i.e. every single post has adsense, but I want adsense only on some of my posts. Thanks in advance
Hi Big Pumpkin,
The only way I can think to do that is to create a new category for the posts you don’t want the adsense on and use a different template for that or those categories. I do this on some sites to rotate different types of banners according to the category.
I’ve been meaning to write up a simplified post on how to do that but haven’t gotten to it yet. Meanwhile, you can get some more info on that here, http://codex.wordpress.org/Category_Templates and here, http://justintadlock.com/archives/2008/12/06/creating-single-post-templates-in-wordpress
Good luck
Hi Gail,
Thanks for reverting so quickly. I read the two links you suggested but it means nothing to me – LOL. I am a total IT retard
I’m just going to wait for you to write your ‘simplified’ post on this topic, because I understood your other posts. Thanks again!
Big Pumpkin, you talked me into it!
How to Set Up Single Post and Category Specific Templates in WordPress
It’s not so easy to “simplify” something so complex, hehe, but I tried!!
Hope that helps!
Tried the insert however all that came up on my page was a 302/252 empty space with my adsense pub number in it
pub-2286xxxxxxxxxxxx
I assumed that it was my adsense id pub number that went in there
I am new to all this coding and may have got it wrong
Be glad of any redirections as would love to have this google ad systen in this spot as everyone recommends it as the winning place on the post or page
Regards Lennie382
Hi lennie382, you need to paste the entire google adsense code in that spot and not just pub-2286xxxxxxxxxxxx
Let me know if you have any more problems.
There’s another way if that doesn’t do it for you posted a few comments up… http://www.wahguide.com/2008/11/technical/how-to-insert-adsense-into-wordpress-post/#comment-26554
Hi Gail,
I’m a total nubie in wordpress. Do you by any chance have a ready to download prosense template that has an adsense ad block in the top left corner similar to yours? Have tried things discussed above and can’t really make that ad block appear! Just a thought… I suppose this will be a very big help to a lot of your subscribers.. Thanks!
Edwin
Hi Edwin, the files you are requesting can be found here. http://wahguide.com/freebies/ProsenseAdsense.zip
If you have any trouble with it, let me know and I’ll be glad to help.
Hello,
so simple, so easy, so useful !!!
Thanks
Thanks for this nice solution. Was banging my head with this problem since 2 days. Actually, i was using the plugin Adsense now, it makes it very simple. But it doesnot put it that neatly. Thanks
Thanks. Right on point! Everyone else was complicating the issue. and I don’t like using plugins for this b/c I’ve noticed the developers will program it to include their adsense to show up on your blog. So I’d much rather go this route. Thanks again!!!