Posts Tagged ‘WordPress Hacks’

AdSense-Deluxe And ButtonSnap Fix

Posted on November 2006 at about 1:23 AM by hwa

If you are using AdSense-Deluxe together with other WordPress plugins that is using ButtonSnap Class Library to create Quicktags button for WordPress Editor, then most probably the buttons created by ButtonSnap won’t show up.

However, after playing around with the JavaScipt inside AdSense-Deluxe (shame to say that i’m not very familiar with JavaScipt 😳 ), finally i came out a solution that’s extremely easy and still maintain the AdSense-Deluxe drop down option in WordPress Editor.

Follow these simple step to do the AdSense-Deluxe and ButtonSnap fix:

Step 1: Open up adsense-deluxe.php with your favorite editor, then search for the following two line.

  1. if (document.getElementById('quicktags') != undefined){
  2. document.getElementById('quicktags').innerHTML +=
  3. ...

Step 2: Then replace the quicktags with ed_toolbar, become like this.

  1. if (document.getElementById('ed_toolbar') != undefined){
  2. document.getElementById('ed_toolbar').innerHTML +=
  3. ...

After that you are done, the button created by ButtonSnap should appear together with AdSense-Deluxe drop down option.

Notes: I tried this plugin in WordPress 2.1 Ella but it doesn’t work for me, so i guess this fix doesn’t apply to WordPress 2.1.

AdSense Between WordPress Post

Posted on October 2006 at about 10:50 PM by hwa

Few days ago a friend of mine asked me how to insert Google AdSense in between posts in the main page, too bad that she is using Blogger and i’m not familiar with it.

Anyway this is how i do it in WordPress, it’s very easy actually, all you have to do is to insert the following code into The Loop:

  1. < ?php
  2. $gcount++; // google post counter
  3.                
  4. if ($gadv < 3) { // how many ads to display?
  5.   if ($gcount%2 == 0) { // display ad after how many post?
  6.     $gadv++; // count number of adv
  7.     print 'Your Google AdSense Code Here';
  8.   }
  9. }
  10. ?>

Don’t forget to insert your own Google AdSense code, and you can put the above code anywhere in your “single.php” as long as it’s in between the line:

  1. < ?php while (have_posts()) : the_post(); ?>

and

  1. < ?php endwhile; ?>

Which is The Loop that i mentioned earlier.

You may want to change the parameter to suit your need, there are only two parameters you can set, first one is:

For the total number of AdSense display in your home page, remember that Google only allow a maximum number of three AdSense displayed in the same page.

The second parameter would be:

  1. $gcount

This one is to set your AdSense to display after the specific amount of post, the default setting is to display AdSense every two post.