WordPress.org

Ready to get started?Download WordPress

Forums

Adsense after random # of posts (14 posts)

  1. acarboni
    Member
    Posted 9 years ago #

    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?

  2. carla
    Member
    Posted 9 years ago #

    Moose Candy might help...at least, it might be a starting point. :)

  3. carla
    Member
    Posted 9 years ago #

  4. Cine
    Member
    Posted 9 years ago #

    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 } ?>

  5. NuclearMoose
    Member
    Posted 9 years ago #

    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.

  6. acarboni
    Member
    Posted 9 years ago #

    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?

  7. acarboni
    Member
    Posted 9 years ago #

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

  8. lcf
    Member
    Posted 9 years ago #

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

    Note: my site is not implementing it now.

  9. longarela
    Member
    Posted 8 years ago #

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

  10. rarrar
    Member
    Posted 8 years ago #

    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!

  11. rarrar
    Member
    Posted 8 years ago #

    Whoops, here's the same code minus the echo :P

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

  12. longarela
    Member
    Posted 8 years ago #

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

  13. evenglen
    Member
    Posted 7 years ago #

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

  14. maaloxx
    Member
    Posted 7 years ago #

    what file does this code actually go in?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.