WordPress.org

Ready to get started?Download WordPress

Forums

Adsense after random post (4 posts)

  1. toocrazy1
    Member
    Posted 2 years ago #

    Hi there,

    I know how to insert adsense after a particular post and it shows up there every time. However, it would be a way better and more effective for my blog if I could insert ads after random post.

    Let's say I have 6 posts per every page. I would like adsense to appear after a different post every time visitor goes to another page or refreshes it. It would also work if I could define several values (after 1, 3 and 5 post for example) and adsense would appear in one of these positions randomly.

    Is there a way/a code/a plugin to do this? Thank you.

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    output adsense ad at random position (of a preset range of positions) with in the loop:

    http://pastebin.com/2WfX1jQH

  3. toocrazy1
    Member
    Posted 2 years ago #

    Thanks, alchymyth, it works!

    I would like to improve this a bit. Is there a way to show two or even three ads in random positions after wordpress posts? For exmaple one ad after 1, 3 or 5 post, the other one after 2, 4 or 6 at the same time?

  4. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    For exmaple one ad after 1, 3 or 5 post, the other one after 2, 4 or 6 at the same time?

    basically by doubling the earlier suggested code; for two ads that could be totally different:
    http://pastebin.com/qkVL8UJV

Topic Closed

This topic has been closed to new replies.

About this Topic