WordPress.org

Support

Support » How-To and Troubleshooting » Adsense after random post

Adsense after random post

  • 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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Michael

    @alchymyth

    Forum Moderator

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

    http://pastebin.com/2WfX1jQH

    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?

    Moderator Michael

    @alchymyth

    Forum Moderator

    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

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