WordPress Plugin for Simple Google Adsense Insertion/Integration
Categories: Wordpress Plugin
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.
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. Google’sAdsense policy mentions to not have more than three adsense block in one page anyway. That’s why I wrote my own Simple Adsense Insertion Plugin for WordPress, to focus on having 1-3 Google Adsense codes saved and use them where ever I want on my site by inserting a simple trigger text to my posts,pages and sidebar.
Installation
1. Unzip and Upload the folder ‘WP-Simple-Adsense-Insertion’ to the ‘/wp-content/plugins/’ directory.
2. Activate the plugin through the ‘Plugins’ menu in WordPress.
3. Go to Settings and configure the options eg. Copy and paste the Google Adsense code that you want to use.
4. Add the trigger text <!– wp_ad_camp_1 –> to a post or page where u want it to appear.
2. Activate the plugin through the ‘Plugins’ menu in WordPress.
3. Go to Settings and configure the options eg. Copy and paste the Google Adsense code that you want to use.
4. Add the trigger text <!– wp_ad_camp_1 –> to a post or page where u want it to appear.
Usage
There are two ways you can use this plugin:
1. Add the following trigger text to a post or page in HTML view
1. Add the following trigger text to a post or page in HTML view
2. Call the function from template files:
<?php echo show_ad_camp_1(); ?>
or <?php echo show_ad_camp_2(); ?>
or <?php echo show_ad_camp_3(); ?>
<?php echo show_ad_camp_1(); ?>
or <?php echo show_ad_camp_2(); ?>
or <?php echo show_ad_camp_3(); ?>
This Plugin in Action
See this plugin in action on Antique HQ.
Download
Donation Option
Donation option can be found on my 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.
Additional Documentation
How to Add Google Adsense to the Sidebar
In order to add Google Adsense on the sidebar using the ‘Simple Adsense Integration’ Plugin you will need to use 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 the Executable PHP code plugin if you don’t have it already. This plugin lets you call php functions from the widgets (it’s 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>
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>
<!- – 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.
No comments:
Post a Comment