Blogging: Not able to show Adsense ads under my 1st post!

Discussion in 'PHP' started by Michel Z., Jun 6, 2007.

  1. #1
    I want to show Adsense ads under my 1st post only (this ad unit will create a gap between the first video and the rest of the videos on my site all the time), but I am not able to do so and get an error as well!

    My site: www.funnyvideopicks.com

    I followed steps explained to me earlier:

    Edit your “theloop.php” file and add this line:

    $cnt=0;

    before “/* Start the loop */ ”

    On the first line after the start the loop add this:


    < ?php
    $cnt++;
    ?>


    Then just before the end of “theloop” put this code:

    < ?php
    if ($cnt==1) {
    ?>
    YOUR ADSENSE CODE HERE
    < ?php
    } ?>


    I don't know what I am doing wrong. Any advise would be great!!

    Please find my blog "theloop.php" file attached.

    Thanks a lot! :)
     

    Attached Files:

    Michel Z., Jun 6, 2007 IP
  2. mediashare

    mediashare Active Member

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #2
    <?php if (have_posts()) : ?>
    
          <?php $ctr = 1; ?>
     
                  <?php while (have_posts()) : the_post(); ?>
    
                      <div class="post" id="post-<?php the_ID(); ?>">
    
                          <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
                          <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    
          <?php if ($ctr == 1) { ?>
      
    
          //adsense
     
    
          <?php } ?>
    
                          <div class="entry">
    
                              <?php the_content('Read the rest of this entry &raquo;'); ?>
    
                          </div>
    
                          <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    
                      </div>
    
          <?php $ctr++; ?>
           
    <?php endwhile; ?>
    PHP:
    Maybe useful
    <?php $ctr = 1; ?> :: Its variable for counter. 1 mean just shown the advertise at first post only. change it as you want. 2, 3, 4 whateva.



    [I]via
    http://www.cosaaranda.com/tips-menyisipkan-iklan-di-antara-posting.htm
    [/I]
    Code (markup):
     
    mediashare, Jun 6, 2007 IP