|
參考:https://www.techperiod.com/separ ... ing-wordpress-blog/
INTEGRATE ADSENSE REVENUE SHARING IN A MULTI-AUTHOR WORDPRESS BLOG
Assume that your blog have four authors. Create separate four adsense ad units with same format in your Adsense dashboard. If you use an ad unit of 468*60 size then create four different ad units with same size and give them the following name (for example) begin1, begin2, begin3, begin4.
Now, create four channels for four authors. Suppose the username the authors are Jit, Somnath, Sudip and Debjyoti. Give the channel name Jit, Somnath, Sudip and Debjyoti respectively and integrate each ad unit to each channel i.e. Jit -> begin1, Somnath -> begin2, Sudip -> begin3, Debjyoti -> begin4.
Note down, the ad slot ids. For example, ad lot id’s are as follows:
begin1 = 111111
begin2 = 222222
begin3 = 333333
begin4 = 444444
Now, open functions.php file of your wordpress blog and paste the following code:
function get_ad_codes($author) {
if($author == 'Jit')
return '111111';
elseif ($author=='Somnath')
return '222222';
elseif ($author=='Sudip')
return '333333';
elseif ($author=='Debjyoti')
return '444444';
else //default if no author found use for admin i.e. Jit here//
return '111111'
}
Use the above function with in <?php ?> tag if necessary.
Now, open the single.php file of your WordPress blog and replace the existing code with the new one:
<ins class="adsbygoogle"
style="display:inline-block;width:468px;height:60px"
data-ad-client="ca-pub-xxxxxxxxxxxxxxx"
data-ad-slot="<?php echo get_ad_codes(get_the_author_login());?>"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
You may use <?php get_the_author(); ?> function instead of <?php get_the_author_login(); ?> too.
Now, clear the cache of the website if you use any cache plugin and the website shows Adsense ads according to author’s post.
As, the blogger template does not support php (it supports javascript), so, you need to modify the above code before using this to Blogger blog. However, there are various Adsense revenue sharing plugins available in the market. But, I always prefer the manual method so that I can bypass unnecessary scripts to minimize page loading time.
參考:https://www.techperiod.com/separ ... ing-wordpress-blog/
|
|