1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

The best WP Plugin to put adsense after first paragraph?

Discussion in 'Blogging' started by maxken75, Oct 12, 2011.

  1. maxken75

    maxken75 Senior Member

    Joined:
    Nov 3, 2009
    Messages:
    872
    Likes Received:
    32
    The best WP Plugin to put adsense automatically after first paragraph of every post of my blog?
     
  2. adbox

    adbox Power Member

    Joined:
    May 1, 2009
    Messages:
    658
    Likes Received:
    107
    Home Page:
    I've got one that can hit the middle of the content and the top of the content, but I've not tried to target the first paragraph.

    It could be done with manual coding... if your content uses <p></p> to define paragraphs.
     
  3. blackhatcodex

    blackhatcodex BANNED BANNED

    Joined:
    Aug 28, 2011
    Messages:
    144
    Likes Received:
    248
    It should be easy enough to code. I'll see if I can come up with something.
     
  4. wickedguy

    wickedguy Supreme Member

    Joined:
    Jul 22, 2009
    Messages:
    1,402
    Likes Received:
    1,379
    Location:
    BHW--> South Africa
    Home Page:
    Here's a quick and dirty one I quickly put together for you. Just add your adsense publisher id, the width and height (the default is 468x60), save the file as whatevername.php ,upload to the wordpress plugins directory and activate!:D

    Code:
    <?php
    /*
    Plugin Name: WP-Save Your ADSENSE Ass :)
    Plugin URI: http://wpsynit.zar.vg
    Description: Display Adsense after first paragraph. 
    Version: 1.0
    Author: wickedguy
    Author URI: http://wpsynit.zar.vg
    */
    
    
    add_filter('the_content', 'add_adsense', 2);
    
    function add_adsense($content){
    
    $c=0;
    $pub_id='pub-01234567890';//<------your adsense publisher id
    $ad_width=468;
    $ad_height=60;
    $ad_channel='';
    $ad_type='text';
    $contents=explode("\n",$content);
    $my_adsense_code='<script type="text/javascript"><!--
    google_ad_client = "'.$pub_id.'";
    google_ad_width = "'.$ad_width.'";
    google_ad_height = "'.$ad_height.'";
    google_ad_format = "'.$ad_width.'x'.$ad_height.'_as";
    google_ad_type = "'.$ad_type.'";
    google_ad_channel ="'.$ad_channel.'";
    google_color_border = "FFFFFF";
    google_color_bg = "FFFFFF";
    google_color_link = "000000";
    google_color_url = "000000";
    google_color_text = "000000";
    //--></script>
    <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>';
    
    $values='';
    foreach($contents as $key=>$val){
    if($c==0){$values .="$val\n\n$my_adsense_code\n";
    $c++;
    }else{
    $values .= "$val\n";
    }
    }
    return $values;
    }
    
    ?>
     
    • Thanks Thanks x 1
  5. Gorush

    Gorush Power Member

    Joined:
    Jul 19, 2010
    Messages:
    737
    Likes Received:
    164
    Location:
    germany
    is this still wh?
    peace
     
  6. Joeusa

    Joeusa Junior Member

    Joined:
    Sep 2, 2010
    Messages:
    169
    Likes Received:
    22
    Quick Adsense plugin will do the job.
     
  7. wickedguy

    wickedguy Supreme Member

    Joined:
    Jul 22, 2009
    Messages:
    1,402
    Likes Received:
    1,379
    Location:
    BHW--> South Africa
    Home Page:
    The code I posted above IS a plugin :)
     
  8. blackhatcodex

    blackhatcodex BANNED BANNED

    Joined:
    Aug 28, 2011
    Messages:
    144
    Likes Received:
    248
    Here...I modified it and added a menu to the dashboard and an input field to include your adsense without having to hard-code it.

    Download:
    HTML:
    http://www.mediafire.com/?28fyam9vj7d9pkn
    Virustotal
    HTML:
    http://www.virustotal.com/file-scan/report.html?id=4eaf28e9dd35975479682f249f3558780e6bba1af409e80d55059a59eea3e42b-1318572800
     
    • Thanks Thanks x 1
  9. blackhatcodex

    blackhatcodex BANNED BANNED

    Joined:
    Aug 28, 2011
    Messages:
    144
    Likes Received:
    248
    That's a nice plugin, but doesn't do what he initially asked...which was to add the adsense after the firsts paragraph. ;)