I want to show you how to to insert Google Adsense ads into your post at WordPress blog (or how to show Google Adsense banners anywhere in your post). Google Adsense is one of the most popular way to earn money on your blog. You can see them on WordPress sidebars, in the beginning of the posts or right after the post…
Usually people are using widgets, plugins or inserting them somewhere into single.php file. But this methods not allowing you to show your Google Adsense banners inside your post, for example somewhere between paragraphs or right in the middle of your post. See the example:
According to statistics, the best places for your Adsense ads are at the top-left corner of the post and somewhere inside your post, that positions will increase number of clicks (CTR) and will increase your revenue. You know how to do top-left corner, but how to insert Google Adsense ads anywhere in your blog post? Well, it’s easy. We will use WordPress shortcode to embed AdSense anywhere inside your posts.
How to Insert Google Adsense Anywhere in Your Blog Post
Creating a shortcode
You need to add the following code into your functions.php file. You can do this in your dashboard, just go to ‘Appearance’ => ‘Editor’ open your functions.php file. Scroll-down to the end of this file and add this code in new line:
function adsenseads() { return '<div id="adsenseads">Put your Google Adsense banner code here</div>'; } add_shortcode('showmyads', 'adsenseads');
Do it like on my screenshot:
Save your changes.
Showing Adsense ads anywhere in your posts
Now you can use this shortcode to insert Adsense into your post, just choose the place in your test and write the following code:
[showmyads]
You can use this WordPress shortcode in posts and pages.
Styling Your Banner
Your Adsense banner can be styled in your style.css file, because it is inserted with div element (id #adsenseads). You can add some merges, float parameters, etc.
An amazing article. It’s nice to read a quality blog post. I think you made some good points in this post.
Hi, like you blog. Have already implemented internal linking and waiting for related post code. Will now see how I can use the adsense code. Thanks.
here it is not working for my blog.please help
Thanks so much, couldn’t be any easier to follow. Great explanation and screenshot!!
How to enable this in Blogger blog posts..?
Thank you for sharing, this a great way to expand the visibility of your adsence ads.
Best plugin for wordpress
http://wordpress.org/extend/plugins/adsense-insert/
I am not using adsense. I am using adbrite,clickbank and adclick media. Can I use this code? Maybe replacing adsense with these?
This code can be used for any ads and codes.
Dear Alex,
Nice presentation and it is very useful and easy, i loved the way you presented it. Thanks I am able to put ads in between the content, Thanks Alex once again
thanks that is nice tip
You each time we write post we have to write [showmyads] in there.
Wooow thankx a lot dude!
is just what i´m looking for, i have try a lot of adsense pluging but none of then fill my needs….
thanks for the post
Absolutely brilliant post.
I just put an Adsense ad in the middle of my blog by following your advise. I now plan to create more such Adsense functions for different sizes.
Thank you very much.
I keep getting an “Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/agtheman/public_html/get2theleague.com/wp-content/themes/silveray/functions.php on line 67” error when I try to save by functions.php file after adding the code.
I did a side-by-side with your screenshot, and other than the inclusion of my Google Adsense banner code, it looks exactly the same. Any idea what’s going on here? Is my theme rejecting this functionality, perhaps?Thanks in advance
thanks
Please do not give wrong directions. It’s not working. Moreover using your code leads to wordpress error denying access to dashboard. Damn.
Hi, did you ever get round this problem? I inserted this code and wordpress won’t let me into my dashboard now, with the errror code aswell!
problem solved, i replaced the functions.php with the original.
After an hour searching for nothing. Finally, I landed to this post. This post is exactly what I need, a dirty quick guide. But if I can mention, shortcode exec php WordPress plugin would be great If you don’t want to remember all of those shortcodes you made.
God bless you! I hope you get into the heaven when you kick the bucket. Thanks!
Thanks for this. Simple but direct to the point.
Is there any way to this for Blogger ?
..would love to see that..
it might be, but I dont know the way to do this.
Hi, alex,
I serched few methods after getting inspired by you post.
I managed to add adsense inside the post for blogger.
Check this: Example :Adsense inside post for blogger
Btw,
what this
add_shortcode
function does?Is it any predefined word press function ?
this code creates a shortcode “showmyads” with function “adsenseads” (this is some kind of “one word link” which will call the function)
Dude,
If I had helped as many people as you have with this one little code, my head would have gotten so big it would have exploded!! YOU ROCK!!!
Now the question. I want two different styles to place in my posts. Lets say one is where the adsense is text or media, but the other is media only. Is there any way to place another block of code in the functions.php and have a different call function like, [showmyads2] ?
Super helpful, exactly what I was looking for! Not to mention, works like a charm.
Nice article.Thank you.
Alex,
Your instructions worked fine! I am developing a new web site and your instructions for embedding Google adsense in between posts worked very nicely. Within 10 minutes of pasting there it was.
One question, however, why when I view the post in which I embedded my new adsense code, my two sidebars do not show up. for my other posts in which I have not embedded adsense between posts, the 2 sidebars show up in excerpt or full view? I appreciate your instructions. Please send me a response. Thanks!
Post I’m referring to:
http://silverpeople.biz/2011/11/more-than-just-a-cruise.html#more-65
I’ve checked your post and everything seems to be ok (I see your sidebars)
Thanks a lot Alex. I went and studied your set of instructions and finally got it. So, I fixed my ads. Has something to do with excluding the appearance of certain ads like the ones at the beginning or end of posts from your home page, but to show on posts. Then you don’t get a conflict. This is what I believe happened before and I did not understand it.
Thank you again for taking time to look at my site.
This didn’t work for me. It caused an add, followed by the final line of code, to appear at the top of my dashboard. It also caused an alignment error on my website.
Can’t think what I did wrong. Maybe it’s just not compatible with my theme.
Shame. I really wanted this to work
Thanks for the nice tip
What if we want to insert Google ads in the left side of our post?
Very useful post i like it.
Keep up good work
Great post and best of all, IT WORKS!!!
Wow, I can modify php code to add adsense with ease. but this one really “ROCKS”. You can put anything in that fuction mate like adding a chitika or other message. Thanks for the info.
Thank you for your post. Very easy to understand tutorial. Use it inside my posts now. Works great!
Great tip
Thanks for sharing this WordPress hack/tutorial. Very helpful and handy.
I tried added the code but it comes up with an error. The file you mentioned to add it to seems like it has different script then the one I am opening up. Could there be another functions.php script I need to add this to?
Very nice article… proved very helpful to me !!
keep updating. such kind of posts help newbies a lot
Thanks, I’ve been looking for something like this. I sort of did know that the Adsense code was manually pasted on the post because it seemed like some of the good bloggers had it on perfect parts of their blog posts.
It means we have to edit all of our blog posts???? I don’t think we all like to do that so, any else way?
hi can you help me modify this code… it didnt work on my theme… thanks
Thanks for the tip. It’s helpful for my web design
Pls i want my google ad to show in the middle but it cant get it to work; pls help
I have tries a lot of tips on how to get adds in between my posts but this one is just on point.
thanks dude for this tutorial..
after struggle with numbers of plugin,
now I can add adsense anywhere in my post without using any plugin..
this is the easiest way
thanks for the sharing….
explain how get multiple types of ads . means how do paste different ads between content admin please explain and how to align that
thanks man! what a great way to achieve this, the only thing I would say is do you think it is possible to add it to every post without adding the shortcode?
that tips is what i’m looking for. Its very helpful.
I’m beginner for adsense. thanks again
Stupid poisonous code, dangerous code, site giving error and no way to get rid of this error.
Thanks for this piece of article on how to insert adsense inside wordpress blog. Am giving a try now. kindly keep it up. Thumb UP
NIce tutorial, Thanks a lot. I’ve used this in a news portal to display ads inside news content.
Awesome Stuff!! Finally i got something working!! Thanks a lot!!
Thanks for the great sharing, My adsense CTR is very low now. I will try your method.
Thanks for the great post.
After i have added in the codes, the ads does appear at the post. However, the following:
‘; } add_shortcode(‘showmyads’, ‘adsenseads’);
also visible at the website.
What have i done wrong?
Nice, I have tried and its running well,
Thanks buddy… pls also post the auto showing ads like that without inserting this shortcode… thanks
Great article…helped me out a lot. Thank you so much.
Hi Alex,
Thanks for the code, it works.
I have been using QUICK ADSENSE plugin but i noticed that ad impression is different in Manually added code and plugin. And the most important thing is during last 45 to 50 days overall income was goes down. I have removed this plugin from one of my website and added manually and just after a day overall income has increase by 20%.
Thanks you again for sharing this code – it works with my wordpress page.
Now I am doing it in my blog. Thanks a lot for an idea.
Thank you, It is working.