and like us on FB

After having a quick look at the plethora of AdSense plugins hosted on WordPress, we were a little blown away by the complexity offered by many of them (particularly those with high rankings). While many were feature rich and excellent plugins, they usually offered far more than was normally required for your average blogger starting out with WP and the inevitable AdSense integration. To address this, we turned an (old) shortcode function into a more robust plugin that’d support what we consider to be the core features… and designed it to be simple to use. While we’ve included a shortcode snippet, we’d recommend downloading the plugin for ease of use, updates, and additional features.

Plugin Features

The plugin currently supports the most basic of features:

  • Up to 10 ad units (we’ll increase this to unlimited in the next version).
  • Conditionally prevent AdSense from displaying on specific posts or pages (from your publish meta box).
  • Display both desktop and mobile ads, with optional adverts for when you switch off AdSense.
  • Exclude AdSense from displaying to users with a specific IP address (displays alternate adverts instead).

Plugin Usage

Download the plugin and activate via your WordPress dashboard. The first thing you’ll need to do once activated is navigate to Tools -> BeliefMedia AdSense and create some ad blocks. Select a block via the Select AdSense Code Block dropdown.

Simple AdSense WordPress Plugin

There are two sections: desktop ads and mobile ads – the latter adverts will render on mobile devices. The alternate adverts display when you’ve chosen to disable ads for a particular post or page, or when you’ve black-listed your IP address. To upload an image, click the upload button and either upload or select an image, or just enter a URL. There are a number of changes we’d like to add here but it’ll have to wait for another version. At the moment it does what it needs to do on the site it was built for.

Disable AdSense Displaying on a Post or Page

There are times when you will want to disable ads from displaying on a particular page – most notably when your page violates Google’s AdSense policy. The option to disable page-level ads is included in your publish meta box.

Simple AdSense WordPress Plugin

Blacklist IP Addresses

To avoid unwanted or accidental clicks, you can list any number of IP addresses that will essentially be blacklisted. When page requests are made via these IPs, the alternate adverts will be shown. Every time you log into the control panel from a new IP address, you will be notified. The IP will automatically be added to your exclusion box (you’ll still need to save it for the IP address to be saved).

Simple AdSense WordPress Plugin

There’s an option to show or hide the ads to your exclusion list.

Usage

When you create an advert option you’ll be presented with the ad block ID. Simply use [adsense type=”1″] for the block you would like to render.

Simple Shortcode Alternative

If you’re after a simple shortcode and don’t want the plugin-based features, consider the following code. Populate each $adsense_code variable in the switch statement and call it as [adsense type=”x”] – where x is the code block. To wrap the block in paragraph tags, use p="1". A single alternative exists for a mobile advert; the expectation is that a single width advert or responsive ad type will be used.

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

Considerations

  • When you create an AdSense ad on Google’s website you will be presented with an option for alternate adverts to render. The alternative advert you select at the AdSense level should normally be the same as the alternative advert you upload via the plugin.
  • The primary ad you select doesn’t have to be a Google AdSense advert; it can be anything.
  • Various text an option formats (and other placeholder images) can be found here.
  • Simple and basic AdSense snippet here.

Download

Title: BeliefMedia AdSense
Description: Display desktop and mobile ads. Option to include alternative self-hosted ads. Exclude posts/pages from displaying ads.
Download: Shortcode (V0.1) | WP Plugin (V0.1) | | Plugin Page

Shortt URL for this post: http://shor.tt/11aM