Adding AdSense to newest entry only (3 posts)

  1. mbalara
    Posted 10 years ago #

    Hi all. I'm a PHP idiot, so a little help goes a long way by me. I'm trying to add AdSense to my page, but I only want one ad block to appear under the newest entry on my home page, i.e. under the first/top entry and nowhere else.

    The way I imagine it is (in plain English):

    If this is newest entry then
    show AdSense code here
    do nothing

    Can anyone translate that into functional PHP?

  2. makemead
    Posted 10 years ago #

    That's exactly what I do on my site: http://www.imaginekitty.com

    <?php if (have_posts()) : ?>
    <?php $count = 0; ?>

    ***stuff that shows your articles***

    if ( $count == 0 ) {

    ***Adsense code here***

    <?php }
    $count ++; ?>

  3. Mark (podz)
    Support Maven
    Posted 10 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic