Adsense for WordPress – my version!

Like a lot of bloggers I use adsense. Up until recently I was using a standard banner at the top of all pages, which was done by using an include in the template files.
Other people seemed to have gone to some trouble to incorporate adsense in their posts, so I thought I’d investigate further.



The original adsense plugin for wordpress isn’t fully compatible with wordpress 1.5, but Liew released a compatible version.
Neither version was capable of placing the code inline so that your post “wrapped” it ie. in the middle of the text, so a bit more digging pulled up another version. It wasn’t compatible with WordPress 1.5 either, so I merged the changes from Liew into the Maxpower version.
You can see the result in this post.
If you would like a copy of my version of the plugin please feel free to download it here
Installing it is very simple.

  1. Download the plugin
  2. Open it in a text editor
  3. Change the adsense code to use your adsense id
  4. Upload it into your plugins directory
    1. You should now activate it via the plugins manager in your admin panel. If everything is installed correctly you will now see an extra button in the editing window labelled “adsense code”
      If you want to edit the position, colours or other attributes, simply open the plugin file in a text editor and make your changes.
      Thanks to the other plugin developers 🙂
Published
Categorised as Random

By Michele Neylon

Michele is founder and CEO of Irish hosting provider and domain name registrar Blacknight.

19 comments

  1. I’ve expanded the inline adsense plugin for WordPress. My version (http://www.acmetech.com/blog/adsense-deluxe/) uses an options panel within your WP admin and allows you to define any number of ad styles and reference them in posts by names, change which style to use as default, globally/selectively enable/disable ads (w/out having to disable the plugin), and includes an AdSense Sandbox tool to preview the ads Google would display for a given web page.
    cheers,
    -wayne

  2. Wayne
    I’ll definitely be giving your version a try. It sounds like you’ve added a lot of very useful options to it.
    Does your version cater for inline ads (as above) ?
    Michele

  3. Yeah, I think so (if I understand what you mean). If you are/were using Phil Hord’s adsense plugin, then mine simply builds upon that one. I started with his and immediately went crazy adding features. With phil’s plugin, you would add the html comment in your post where you wanted your ads to appear. Mine works exactly like that except if you simply use that placeholder, you get the ad style which you have designated as your “default” style. Amongh all the ad styles you configure, you can easily change which one is “default” and all the ads in all the posts which are refenced with change. However, each style is defined with a unique name, so you can also reference the styles with something like . This makes it trivial to use different ad styles within a single post.
    -w

  4. Michele,
    show me an example of what you’re trying to do. Just show me a snippet of the inline css and a portion of the adsense code (you’ll want to escape the javascript stuff, or otherwise upt it in here so that it doesn’t actually pull ads into the comment).
    Alternately, email me a sample, you have my email address in my user registration.
    -w

  5. I tried wrapping one of my ads in your style code. Since the adsense-deluxe plugin simply replaces the html comment with WHATEVER you define in the options admin, the style info was added to the web page when I reloaded it.
    However… I noticed a bit of a problem in that wrapping the javascript with a styled tag resulted in a netsted paragraph since in my installation of WP it seems to be auto wrapping my content in tags. To wit:
    (this is what came out in the html…)

    so two points:
    1) you shouldn’t have any problem adding style info (or anything else you want) within the adsense block definitions and having that substituted into the posts. If that’s not happening for you, let me know since it worked on my setup.
    2) It might be more appropriate to use the tag instead of the paragraph.

  6. well, that didn’t work. my pasted html sample was stripped or isn’t rendering. Let me just use alternate tags… in my web page after adding your styled [p] wrapper, I got:
    [p][p style=”blah blah”]
    [script … adsense script here]
    [/p]
    ….. my initial paragraph of content….
    [/p]

  7. AFAIK this is against AdSense TOS. Because currently AdSense prohibits you from including AdSense code in feeds(unless they have selected you for their AdSense for feed trial). If this plugin is used and you provide full feed to your users then you are essentially including AdSense Ad in feeds also.

  8. And Michele, are you doing “full feeds”?
    I guess I’ll have to investigate that as well… but if you are doing full feeds and no ads are getting inserted, then it’s most likely because I’m not registered as a feed filter.
    I’ll have to investigate this some more.

  9. Michele,
    I’m trying your plugin but it is only working on my index page and not individual posts.
    Any changes to be made for ad to appear in posts?

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Exit mobile version