Sunday, 27 March 2011

0 comments
If the post that you are writing is a longer one, you might want to insert or embed an adsense ad in between the content so that you can monetize your longer content.
You can achieve this by pasting a small function in your active theme’s functions.php and then using a simpe shortcode [adsense]
Code to paste in functions.php :
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function create_adsense_shortcode( $atts ) {
    extract(shortcode_atts(array(
            'size' => '1'
    ), $atts));
    switch ($size) {
     case '1' :
        $ad = '<div class="inpost_ad">
              <script type="text/javascript"><!--
              google_ad_client = "pub-xxxxxxxxxxxxxxxx";
              /* 336x280, created 4/8/09 */
              google_ad_slot = "xxxxxxxxxx";
              google_ad_width = 336;
              google_ad_height = 280;
              //-->
              </script>
              <script type="text/javascript"
              src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
             </script>
               </div>';
     break;
     case '2' :
        $ad = '<div class="inpost_ad">
                   <script type="text/javascript"><!--
                google_ad_clien

0 comments:

Post a Comment