Support » Plugins » Hacks » Google Ad between first and second post

  • I’m trying to figure out a way to put a Google Ad between the first and second post on my blog. So far I haven’t found a current way to do this with the Twentyten theme. Any help is appreciated.

Viewing 1 replies (of 1 total)
  • Michael


    Forum Moderator

    i assume you have found loop.php ?

    and the actual loop code showing the front page ?

    and particularly the line <?php endwhile; // End the loop. Whew. ?> a few lines from the end ?

    before that line, add your adsense code, ideally wrapped into a div with a css class for formatting; and definitively surrounded with some extra code; for instance:

    <?php if( !$ad_shown ) { ?>
    <div class="adsense">
    <script type="text/javascript"><!--
    google_ad_client = "pub-0123456789098";
    /* adsense_ad */
    google_ad_slot = "123456789";
    google_ad_width = 468;
    google_ad_height = 60;
    <script type="text/javascript"
    <?php $ad_shown = true; } ?>

    be aware that this will now show adsense in most page with multiple posts – i.e. not only on the front page, but also in archives, search results, etc.

Viewing 1 replies (of 1 total)
  • The topic ‘Google Ad between first and second post’ is closed to new replies.