How to implement different adsense unit for depending on authors..

Discussion in 'HTML & Website Design' started by Khaludi92, Mar 29, 2010.

  1. Khaludi92

    Khaludi92 Member

    Messages:
    259
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #21
    I pasted the Code You gave me, and changed the author #1 with the authors name and added the adsense code when its says author1 adsense code and author 2 adsense code, this is what i got

    <?php
    function author_adsence () {
    global $post;
    global $wpdb;
    global $post_id;

    $content_new = $content;

    if(isset($_GET['author_name'])) :
    $author = get_userdata($_GET['author']);
    if($author== "madhi"):
    $topadsence = <script type="text/javascript"><!--
    google_ad_client = "pub-xxxxxxxxxxxxx";
    /* 336x280, Large Rec, */
    google_ad_slot = "yyyyyyyyyyyy";
    google_ad_width = 336;
    google_ad_height = 280;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    else:
    $bottomadsence = <script type="text/javascript"><!--
    google_ad_client = "pub-xxxxxxxxxxxxxxxxxxx";
    /* 336x280, Large Rec, */
    google_ad_slot = "zzzzzzzzzzz";
    google_ad_width = 336;
    google_ad_height = 280;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    endif;
    else :
    $topadsence = <script type="text/javascript"><!--
    google_ad_client = "pub-xxxxxxxxxxxxxxx";
    /* 336x280, Large Rec, */
    google_ad_slot = "yyyyyyyyyyyyyy";
    google_ad_width = 336;
    google_ad_height = 280;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    endif;
    $content_new_with_adsence .=$topadsence;
    $content_new_with_adsence .=$content_new;
    $content_new_with_adsence .=$bottomadsence;

    return $content_new_with_adsence;
    }

    add_action('the_content', 'author_adsence', 9);
    ?>
     
    Khaludi92, Mar 30, 2010 IP