Title: Adsense after random post
Last modified: August 20, 2016

---

# Adsense after random post

 *  [toocrazy1](https://wordpress.org/support/users/toocrazy1/)
 * (@toocrazy1)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/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)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/adsense-after-random-post/#post-2649098)
 * output adsense ad at random position (of a preset range of positions) with in
   the loop:
 * [http://pastebin.com/2WfX1jQH](http://pastebin.com/2WfX1jQH)
 *  Thread Starter [toocrazy1](https://wordpress.org/support/users/toocrazy1/)
 * (@toocrazy1)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/adsense-after-random-post/#post-2649172)
 * 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?
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/adsense-after-random-post/#post-2649225)
 * > 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](http://pastebin.com/qkVL8UJV)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Adsense after random post’ is closed to new replies.

## Tags

 * [after](https://wordpress.org/support/topic-tag/after/)
 * [after post](https://wordpress.org/support/topic-tag/after-post/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/adsense-after-random-post/#post-2649225)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
