Easy to use WordPress plugin to insert Google Adsense to your posts, pages and sidebar by using a trigger text or calling the php function.
There are many plugins and services which can add Google Adsense to your WordPress site. However I found that even though something like Adsense Manager or Adsense Deluxe provides a lot of customizable options, it can be overwhelming and isn’t really simple enough for people who are new to WordPress or for people who simply want to insert Google Adsense to their site in a few clicks.
Google’s Adscense policy.
I found that most of the time I only use two or three types of Google Adsense units in various places and posts throughout my sites. So I wrote my own Simple Adsense Insertion Plugin for WordPress, to focus on having 1-5 Google Adsense codes saved and use them where ever I want on my site by inserting a simple shortcode to my posts, pages and sidebar.
Simple Google Adsense Plugin Installation
- Unzip and Upload the folder ‘WP-Simple-Adsense-Insertion’ to the ‘/wp-content/plugins/’ directory.
- Activate the plugin through the ‘Plugins’ menu in WordPress.
- Go to Settings and configure the options eg. Copy and paste the Google Adsense code that you want to use.
- Add the trigger text [wp_ad_camp_1] to a post or page where u want it to appear.
Simple Google Adsense Plugin Usage
There are two ways you can use this plugin:
1. Add one of the following shortcodes (trigger text) on a post or page
- [wp_ad_camp_1]
- [wp_ad_camp_2]
- [wp_ad_camp_3]
- [wp_ad_camp_4]
- [wp_ad_camp_5]
2. Call one of the functions from your theme’s template file:
- <?php echo show_ad_camp_1(); ?>
- <?php echo show_ad_camp_2(); ?>
- <?php echo show_ad_camp_3(); ?>
- <?php echo show_ad_camp_4(); ?>
- <?php echo show_ad_camp_4(); ?>
Using In-Article Ads
This plugin allows you to automatically insert adsense ad code after the 2nd paragraph of every posts. If you want to use this feature then copy and paste the ad code in the In-article Ad Code field of the settings menu of this plugin.
Adding Adsense At the End of Every Article
This plugin allows you to automatically insert ad code at the end of every article. Go to the settings menu of this plugin then enter your ad code in the Post-article Ad Code field to activate this feature.
Plugin Download
Download the Google Adsense Plugin.
Compatibility
Works with the latest version of WordPress.
Requires
Requires WordPress 4.0 or higher.
Donation Option
Donation option can be found on our projects page.
Change Log
- Version 1.1 – Fixed an issue whereby sometimes Google Adsense code were disappearing from the settings page in some WordPress themes.
- Version 1.2 – Devlin from wptheming.com added proper shortcode implementation for placing the ads (this way you don’t have to use the old filtering options anymore)
- Version 1.3 – Added shortcode filtering on sidebar
- Version 1.4 – Added shortcode filtering on widget text and excerpt
- Version 1.5 – Added a 5th ad slot
- Version 1.6 – WordPress 3.8 compatibility update
- Version 1.7 – WP 4.2 compatibility
Additional Documentation
How to Add Google Adsense to the Sidebar
You can use the shortcodes (example: [wp_ad_camp_1]) in the sidebar to show Google Adsense ad in the sidebar widget. Simply ad a text widget to your sidebar and place the shortcode in there.
Alternatively, you can add Google Adsense on the sidebar using the ‘Simple Adsense Integration’ Plugin by using the following PHP function:
<?php echo show_ad_camp_1(); ?>
If you are calling the function from the theme’s template file (sidebar.php) then you are fine but there is another way to do this using the widgets which could be more practical in some cases.
1. Download and activate a PHP code executable plugin if you don’t have it already. This type of plugins allow you to call PHP functions from the widgets (it is similar to the Text widget but it lets you execute PHP code too).
2. Go to the widgets menu and add a ‘PHP Code’ widget to the sidebar (where you want to display the Google Adsense block). Now add the following line of code and save the settings:
<?php echo show_ad_camp_1(); ?>
This will display an The Google Adesne ad that is saved in the number one textarea of this plugin.
How to Wrap Text Around a Google Adsense Block
To left align the Adsense block and wrap text around it just use the following div for the Adsense unit in HTML view:
<div style="float: left;"> Adsense Goes Here </div>
To right align the Adsense block and wrap text just change “float: left;” to “float: right;”. So for an example, the following will left align the Adsense Unit that is saved in the Ad Campaign 1 box and wrap text around it.
<div style="float: left;"> [wp_ad_camp_1] </div>
If you need help with this plugin or want to suggest an enhancement/feature then please let me know by leaving a comment in the comment area below.
Also, check out our list of best WordPress plugins to find out what other plugins you should be using.
Super-Duper site! I am loving it!! Will come back again – taking your feeds also, Thanks.
thank you very much!
it’s best plugin!
@Jim, do I need to add it to every post and every page? – the answer is no. If you have a set place where you want to add the google adsense unit then you can just add it in the template file of the post and that will be applied to every post. For example, here on tips and tricks HQ I show Google Adsense unit at the end of every post below the comments section. So I have updated the template file of my posts (e.g post.php) to have the php function call.
In order to do what I did… search for the following line in your posts template file:
<?php comments_template(); ?>
Then add the following line of code immediately below that line:
<?php echo show_ad_camp_1(); ?>
Remember, the trigger texts are to be used if you want to show the google adsense unit inside the posts content (eg. in the middle of the article). To show the google adsense unit anywhere else just use the php function from your template file.
@Sean, did you add the trigger text in HTML view?
Hello … please forgive this dumb question … steps 1-3 of the install process are easy and I’ve got those done. However, step four says:
4. Add the trigger text to a post or page where u want it to appear.
Ok … do I need to add it to every post and every page, and if so, where exactly do I add it? At the beginning of the post, at the end of the post?
Is there a way to add the trigger text once so AdSense appears automatically on every page of the site?
Thank you ….
whoops. Just saw the posting and the trigger text i typed didn’t appear. i guess you get the idea though. my site is at letmeteach.com if you get a chance to take a look. thanks!
Hi!
Thanks for the plug in. I was very excited about it since I haven’t had any luck getting AdSense ads to appear on my page. Unfortunately, I still don’t see anything. I’m wondering if I just don’t understand how to do it. Here’s a sample of the trigger text in a post:
<!– wp_ad_camp_1 –>One of the most labor intensive early steps to applying for teaching positions is the creation of a good resume.
My code appears in the windows under settings for your plug in also.
Is it the template I’m using that’s the problem? Heeeeeeeeeeeeeeeelp!
s.
@Jeff, I understand your concern. unfortunately I haven’t uploaded the latest version on wordpress site yet.
I really like the looks of you plugin, but am super-cautious about downloading programs from sites I am not familiar with. Do you have this available on the wordpress-extend-plugin site? I only saw version 1.0
Thanks,
Jeff H
Hi, I cant understand how to add your site in my rss reader. Can you Help me, please 🙂
Hi
Thanks for the plugin. I unfortunatly had problems with it aswell. I inserted my ad codes and all worked well until I needed to edit one of the codes, I went to settings to see that all ad codes wernt there and the boxes were empty. I just tried re-inserting the code I wanted to edit and pressed update options to see if that worked. I ended up wiping the other two ad blocks away although the edited code worked. Seems abit daft that if you want to edit one ad code you have to insert all three again????
My suggestion for future releases would be :-
1. Code stays visible for each ad slot and can be edited
2. Able to add more ad slots so you can use diferent ad networks or for affiliate links.
Thanks again for the plugin
ooops just fixed the disapearing code by updating to newest version, should of read propely….
Hi, admin.
I just install and make setting for your plugin.
I tried a lot of Google Adsense’s manager plugins 4 WP but yours is the easyest and customized one.
Next days i will going to add the code in each posts.
If i get some free time i will translate with pleasure your plugin in italian language.
Please show me where insert the italian phareses in php code plugin.
MANY THANKS 4 YOUR PLUGIN
Regards
Leave me a mex in my blog
Yes, the Google Adsense Integration plugin works with WordPress 2.7.1
Hi.
do your plug in works with wordpress 2.7.1.
Thanks
@Mark, Yes u can use this plugin to wrap text around a google Adsense block. I have updated the post with the information you need… please see the “How to Wrap Text Around a Google Adsense Block” section in the post above.
Can I used this plugin to wrap text around an adsense block? If so, how?
Mark
Copy and Paste the Ad code for the leaderboard ad to one of the ad campaign text area of the Adsense Ad integration plugin then open the header.php file of your theme and use the corresponding function to show the ad
When you ad the above line to your header.php file, it will show the leaderboard ad in your header… you will have to put it in the right div block though so it aligns nicely where you want the ad to appear.
If I want to put a leaderboard ad in my header, how do I do that? On my site, you can see where it will go in the header.
Thanks!
To place ad on the sidebar you can just call the corresponding function for that ad. For example the following line will show the ad that you saved in the first ad campaign field:
You can just call these functions from your templates sidebar.php file or there is a plugin called “Executable PHP Code” that lets you add php widget that you can use to execute any php code. The plugin can be downloaded from the following URL
http://wordpress.org/extend/plugins/php-code-widget/
First of all I would like to say thank for this plugin. It is great.
I am trying to place ads on side bar, and one with any info?
FINALLY an adsense-plugin, that works very well and where I can place the ads whereever I want!
Many, many thanks!
If you are talking about changing the color of the Adsense unit then you will have to do it from your Google Adsense Account. If you have already created the Adsense unit then log into your Adsense account and you will be able to change the color by selecting “Edit Ad Settings” from the “Manage Ads” menu under “Adsense Setup”.
thank you got it working, but how to change the color ?
hello admin
i was first creating a new post on my wp with theme freshnews, but i cannot save it, it just hangs on the browser like reading or loading.
what i did is search for google adsense on wp and landed on this page
so i installed the insertion plugin.
but again, once i tried to update the settings and put the code and hits the update
the browser still does not respond again. it just keeps on reading
is there somthing wrong with my adsense code and the wp cannot save it
hope to hear from you thanks
great plugin if this will work.
@Gary, Please use version 1.1 of the WordPress Google Adsense Integration Plugin which has the fix whereby sometimes Google Adsense code were disappearing.
To Place google Adsense in the sidebar… Please read one of the comments above that I posted earlier.
My ad code is disappearing? Won’t hold it? Ideas? I can’t seem to place code in the side bar? Thanks in advance…!
Never mind. I got it working!
I can’t seem to get this to work. I used and just dropped it into my header file. Any suggestions.
Updated version released with the fix whereby Google Adsense Code was disappearing
@Ed, To use the Google Adsense on your sidebar using this plugin you need to use the second method which is call the php function from your sidebar.php file or if you use the Executable PHP Widget plugin then you can call the php function using that plugin.
Regarding the issues… its been a while since I released this plugin and since then WordPress has had a few releases so I will have a look at the plugin code and release an updated version (Its on my list of things to do but the list just keeps growing :).
One more thing…
It DOES matter that the code disappears from the textarea, because if the box is blank for number 1, and you add code for number 2, the ad for number 1 disappears.
Just found out I can’t post my html code. Sorry.
I’m trying to use the Text widget to add a Google add to my sidebar. Is that the proper way to do it? It doesn’t seem to work. It is, however, working beautifully in my posts and pages.
This is what I have in my Text widget:
I’ve also tried this:
@Andy, yes it is possible to place Google Adsense anywhere on your blog page with this plugin. To place a square ad in between the Post title and the Post body, simply copy the the Adsense code for the square ad to one of the Ad campaign code blocks in the Settings of this plugin then use the corresponding tag in your article. Make sure you put the corresponding tag in HTML view as the first line of your article and that should show the ad between the title and the body.
You will have to sign up for Google Adsense from the following URL and then create an ad to get the Adsense code.
Google Adsense
Where do you find the google adsence code to copy? Sorry, newbie.
Hi,
I am very interested in this plug in. I would like to be able to place a square google ad block between the title of my post and the post body. I am not sure from what I have read if this is possible with this plugin. If so, can you tell me where to place the code. I am new to programming to I need to know exactly what code to add where.
Thank you very much for any help you can provide.
Hi admin,
Thanks for the reply.
Yes, I thought it may take some time, so I left it overnight, but this morning… still no ads!
I copied and pasted (into notepad first just to make sure) exactly the text as it appears and … still no joy!
What else can I try?
Hello Luci, Just thought I would mention this… don’t forget that sometimes it takes about half an hour (even though it says10 minutes) for your Google Adsense unit to start working after you create it. So if you just created the Adsense unit then you will need to wait a little bit before the ad starts to appear. Also, please make sure you are using the trigger text exactly as it is stated in the Readme.txt file… sometimes its easy to miss a ‘space’ or capitalize a letter etc.
Hello
I am having problems getting this plugin to work!
I copied all the instructions to the T. Copied and pasted in HTML mode, but like the above poster, the text just disappears out of the box! OK, you said not to worry about that – it should still be stored… but, despite putting the trigger text into the post… no adsense shows up at all!
Any suggestions?
Thanks for your time in answering this question.
This is exactly what I was looking for, thanks!
To start earning money with your blog, initially use Google Adsense but gradually as your traffic increases, keep adding more and more money making programs to your site.
Great plugin… very easy to use. Definitely made the use of Google Adsense on my blog easier. Thanks for this Plugin.
Yes, the Google Adsense Insertion WordPress Plugin will work fine for Link units and Search bars.
will your adsense pluin work for an Adsense Search Bar and an Adsense link unit?
Thank you so much for your perfect reply. I have done exactly what you have instructed and it would not work which was why I posted!
After I read the reply I figured I would just try it again and it worked perfect!!!!! The only problem I see now is in the google code, there are two angle brackets in the ad section. I will check out there and get another code.
This worked like a charm and I just LOVE the easy of placing goggle ads.
THANK YOU SO MUCH!
Captain Ed & Donna
Hi Captain Ed & Donna,
Lets try to get your plugin to work properly. This plugin is used by a lot of people including myself and I haven’t heard any complains yet so I have a feeling that in your case it’s not working for some silly reason. I am going to give you a few pointers to try and hopefully this should fix it.
1. There is no reason to explicitly save your Google Adsense code in the Campaign code text area. All you need to do is copy and paste the Google Adsense code in one of the Ad Campaing code text areas and Hit “Update Options” (This will save the adsense code). The “Update Options” button is located in the lower left hand corner.
2. Now you can use the trigger text e.g. to display that ad in your post or pages. Make sure when u add the trigger text to your post or pages, you do it from the “HTML” view and not from the “Visual” view. You can switch between the “HTML” and “Visual” view by clicking the button on the upper right hand corner of the post or page editing menu.
3. Make sure you copy and paste the Full Google Adsesne ad code from your Google Adsense account into the Ad Campaign code text area and hit “Update options”. Don’t worry if the Ad text doesn’t stay in the text area. It is stored in the variable and should work fine when you use the trigger text.
Let me know how you go. Cheers!
Hi,
I have downloaded the adsense plugin and was very excited, but can’t get it to work. I am using WP and when I put the google adsense in the campaign 1 box it doesn’t stay..disappears. I have looked all over for a save button or something but can not find it.
When I put the trigger code in the page it doesn’t get the adsense code because it is no longer in the box!
What can I do?
Thanks sure looks like it would make my life easier…
Captain Ed & Donna
How about a plugin for Google Ad Manager? Would be nice to have a plugin that allows you to tag posts so that a corresponding widget to display appropriate Ad Manager ads in the sidebar (or the posts for that matter)
Great plugin thanks