php code help for wp revenue sharing

1 replies
I have a revenue sharing site that up until recently was using a plugin to display adsense for each author by channels... this is taking me forever to add the code for a new author and I'm trying to make this easier for myself by only having to add code once on author sign up. So here's what I've done so far to no avail..

I added this to my mu.functions.php file to associate the author with a particular channel in adsense using the "ad slot" number.

function adsense_sharing($author) {
if($author == 'admin')
return 'xxxxx';
elseif ($author == 'xxxx')
return 'xxxxx';
elseif ($author == 'xxx')
return 'xxxxx';
else
return 'xxxxx';
}
?>

with the "xxx" being the author name and google ad slot #

then.. I added this to my single.php

<div style="float:right;"><script type="text/javascript"><!--
google_ad_client = "pub-xxxxx";
/* Snurtl */
google_ad_slot = "<?php echo adsense_sharing(get_the_author());?>";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>

ok.. so if i view the source it shows the ad code fine.. just like it's supposed to be..It's showing the correct ad slot # for the author.. but the ad doesn't show, just a blank space so I obviously am missing a space or comma or something. when I copy the code directly into the template from adsense obviously it works fine...

No my domain is not blacklisted or banned.

solved: funky quotes in "<?php echo adsense_sharing(get_the_author());?>";
#code #php #revenue #sharing
  • Profile picture of the author newmoon
    I guess ad slot ads will not be displayed this way. ads slots are registered to specific adsense publisher. you have to put old ads code and replace the pub code.

    Code:
    <script type="text/javascript">
    google_ad_client = "ca-pub-xxxxx";
    google_ad_width = 468;
    google_ad_height = 60;
    google_ad_format = "468x60_as";
    google_ad_type = "text_image";
    google_color_border = "FFFFFF";
    google_color_bg = "FFFFFF";
    google_color_link = "3C6080";
    google_color_text = "000000";
    google_color_url = "3C6080";
    </script>
    {{ DiscussionBoard.errors[2158071].message }}

Trending Topics