WordPress Hack – How to Share Adsense Revenue with Multiple Authors?

If you run a wordpress blog that has multiple contributors and would like to award contributors by sharing adsense earnings, read on.

Follow these simple steps

wordpress weekend

wordpress weekend

Step 1: Create an adsense channel for each author.

Step 2: Create ads (in adsense) and assign them under the specific author channel. Note the slot id for each ads.

Step 2: Add this code in your wordpress theme’s functions.php file (replace author1/author2 with author names, and slot id with author’s slot id)

function adsense_code($author) {
if($author == 'author1')
return '<slot id_author1>';
elseif ($author == 'author2')
return '
<slot id_author1>';
else // default author
return '
<slot id_admin>';
}

Step 3: Depending on where you want to showcase the ads, insert your adsense code (ensure that all the ad formats are same)

google_ad_client = "pub-id";
google_ad_slot = "< ?php echo adsense_code(get_the_author()); ?>";

Explanation/How this works?

What you have done is that

  • For each ad format, you assigned an ad slot to each of your authors.
  • Based on author’s slot id (which is picked up by the function), author’s ads will be shown on the site and earnings can easily be reported on the corresponding channel.
  • Note that author name in the function adsense_code is same as author’s display name (if you want, you can use author id as well).

Simple? Got questions? Leave them in the comment section.

 
  • Related Articles

    1. If I Were A Book – Connecting Authors with International Print Publishers
    2. Interesting Orkut Hack
    3. Politicians gets adsense(d)
    4. Interview with Pothi Founders : "Our mainstay is going to build a community of authors and readers"
    5. WordPress Weekend – Bringing All Things WordPress Together
  • comment(s) on WordPress Hack – How to Share Adsense Revenue with Multiple Authors?

    One Response to WordPress Hack – How to Share Adsense Revenue with Multiple Authors?

    1. Carol says:

      Much thanks for yet another first-rate post. I am always trying to find good WordPress tricks to recommend to my own readers. Thank you for taking the time to write this tutorial . It’s just what I was looking for. Truly awesome post.