Support » Themes and Templates » Adsense after random # of posts

  • I currently have adsense installed into the menu of my blog http://www.evilprimate.com . I’m looking to place it inthe main content column of my blog, after the third post on the page. Not being any kind of coder at all, I can only seem to get adsense (try) to show up after every post on my index page. I’m using the kubrick theme on WP 1.2. Can anybody give me any pointers on how to get this working?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Moose Candy might help…at least, it might be a starting point. 🙂

    Try this. Just put it inside your loop where you want the AdSense to show up.

    <?php $i++; if($i%3){ ?>
    ADSENSE CODE HERE
    <?php } ?>

    Moose Candy was designed for exactly this purpose. You can set it up to put any kind of content you want virtually anywhere…after the first post, the fifth post, or any combination you want.

    Hey, everyone —

    Thanks for the suggestions… the php code Cine left me didn’t quite work… it seemed to want to post the google ad after each one of the first 3 posts. I tried changing

    if($i%3)

    to

    if($i=3)

    and got similar results.

    NuclearMoose, I tried the MooseCandy plugin, but it didn’t display anything when I inserted Google’s javascript code. However, it worked perfectly with the example strings. Is there something I have to change to get moosecandy to work with code?

    Strike that, sorry… it didn’t work with the example strings OR the code.

    I have the random adsense placement code at:
    http://wordpress.org/support/topic.php?id=12685

    Note: my site is not implementing it now.

    In googlepagos.com you can view tools for AdSense…. The AdSense Calculator, Google Dance and Others

    rarrar

    (@rarrar)

    Cine’s code is correct, however, I believe variable “i” is already taken by wordpress. To correct Cine’s post, just change “i” to anything else… in the following example, I changed it to “adpostcount” and voila, it works!

    <?php $adpostcount++; if($adpostcount==3){ echo ($adpostcount)?> put your code here <?php } ?>

    ^^^ The code above will work. Place it before <?php endwhile; ?> and change “3” to whichever number you want and change “put your code here” with your ad code.

    Here’s my basic contribution to the community. Thanks again Cine!

    rarrar

    (@rarrar)

    Whoops, here’s the same code minus the echo 😛

    <?php $adcount++; if($adcount==3){ ?> put your code here <?php } ?>

    longarela

    (@longarela)

    Now Googlepagos is TodoAds and is in http://www.todoads.com

    wow cine’s code works wonders. glad i found it.

    maaloxx

    (@maaloxx)

    what file does this code actually go in?

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Adsense after random # of posts’ is closed to new replies.