Trying To Load More Than 3 Sets of Ads

Discussion in 'Guidelines / Compliance' started by mattfalcus, Feb 6, 2006.

  1. #1
    I have my new blog set up to display Adsense adverts after each post. However, obviously because you are only allowed 3 sets of adverts per page only the first 3 will appear.

    Will I get Google annoyed by this, since the page is in theory trying to load 6 or 7 sets of adverts. Will they think I'm spamming?

    If it is bad, can anyone suggest a way to make WordPress only display ads after the first 3 posts?


    Thanks
    Matt
     
    mattfalcus, Feb 6, 2006 IP
  2. Riboflavin

    Riboflavin Well-Known Member

    Messages:
    1,091
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    155
    #2
    Yes, you could get a penalty from google.

    Here is what I did to show adsense in my first three posts on my entertainment blog:

    --------------------

    Open you theme folder and edit your index.php:

    The first line should be:
    <?php get_header(); ?>
    Code (markup):
    Change it to:
    <?php get_header();$adsense=1; ?>
    Code (markup):
    --------------------

    Then scroll down in the index.php keeping in mind this is the file displaying your home page, so things like
    Posted by <?php the_author() ?> on 
    Code (markup):
    should kind of let you know where you are.

    Find were you want your adsense to be inserted and add this code:
    	<?php if (!is_preview()): ?>
    
    <?php
    
    if ($adsense <= 3) {
    
    echo "
    
    <script type='text/javascript'><!--
    
    google_ad_client = 'USE YOUR PUB ID';
    
    google_alternate_color = 'FFFFFF';
    
    google_ad_width = 468;
    
    google_ad_height = 60;
    
    google_ad_format = '468x60_as';
    
    google_ad_type = 'text_image';
    
    google_ad_channel ='';
    
    google_color_border = 'FFFFFF';
    
    google_color_bg = 'FFFFFF';
    
    google_color_link = '0000FF';
    
    google_color_url = '000000';
    
    google_color_text = '000000';
    
    //--></script>
    
    <script type='text/javascript'
    
      src='http://pagead2.googlesyndication.com/pagead/show_ads.js'>
    
    </script>";
    
    $adsense++;
    
    }
    
    ?>
    
    <?php endif; ?>
    Code (markup):

    --------------------------


    Keep in mind this code at the start:
    <?php if (!is_preview()): ?>
    Code (markup):
    and this code at the end:
    <?php endif; ?>
    Code (markup):
    are only for wordpress 2.0 If you are using an older version, remove those two lines.

    Let me know how it works out or if you need help. Any DP member is free to use this code, just dont claim it as your own :)
     
    Riboflavin, Feb 6, 2006 IP
  3. mattfalcus

    mattfalcus Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the help Riboflavin!

    However, I get the following error message:

    Parse error: parse error, expecting `','' or `';'' in /vhost/vhost3/t/e/e/teesvalleyblog.co.uk/www/wp-content/themes/default/index.php on line 28


    Line 28 is:

    <script type="text/javascript"><!--



    Matt
     
    mattfalcus, Feb 6, 2006 IP
  4. Riboflavin

    Riboflavin Well-Known Member

    Messages:
    1,091
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    155
    #4
    That is because you did not use my ad format, you copy pasted :p

    Just change all the double quotes to single quotes.
     
    Riboflavin, Feb 6, 2006 IP
  5. mattfalcus

    mattfalcus Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Oh I've worked it out. Change the " to '


    Works a treat now. Many thanks for that!!


    Matt
     
    mattfalcus, Feb 6, 2006 IP