Title: [Plugin: Widget Logic] Randomize Widgets
Last modified: August 20, 2016

---

# [Plugin: Widget Logic] Randomize Widgets

 *  [johndjs](https://wordpress.org/support/users/johndjs/)
 * (@johndjs)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-widget-logic-randomize-widgets/)
 * Can you please provide the code/input I need to either randomize my widgets or
   show just a new widget every click.
 * I would like to use this with my Ads.
 * Many Thanks
 * [http://wordpress.org/extend/plugins/widget-logic/](http://wordpress.org/extend/plugins/widget-logic/)

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

 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-widget-logic-randomize-widgets/#post-3024456)
 * Using widget logic for that wouldn’t ‘scale’ very well, and would probably prove
   fiddly to get the effect you are after. I am sure there are ‘ad rotator’ plugins/
   widgets out there you might find more productive.
 *  Thread Starter [johndjs](https://wordpress.org/support/users/johndjs/)
 * (@johndjs)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-widget-logic-randomize-widgets/#post-3024463)
 * Believe me I tried but what I really need is somehow to Randomize my widgets 
   in any chosen widget area, or simply loop each widget one by one of course.
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-widget-logic-randomize-widgets/#post-3024496)
 * it depends on the exact effect you are after. If you want 1 of N widgets to appear,
   you could do this
 * widget 1 (the first one defined):
    `global $widget_rnd; $widget_rnd=rand(5, 15);
   return (1==$widget_rnd);`
 * widget 2
    `global $widget_rnd; return (2==$widget_rnd);`
 * and so on. (nb, i’ve not tried this out.)
 *  Thread Starter [johndjs](https://wordpress.org/support/users/johndjs/)
 * (@johndjs)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-widget-logic-randomize-widgets/#post-3024497)
 * No, both widgets just dont appear anywhere now?
 * Thanks for trying to help
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-widget-logic-randomize-widgets/#post-3024529)
 * ugh copy/paste error
 * `rand (1,2)`
 * this bit generates a random integer between the 2 values. so use (1,n) depending
   on the number of widgets involved.
 * I still think there must be an ad rotator out there to suit you – it’s basic 
   stuff for a blog.
 *  Thread Starter [johndjs](https://wordpress.org/support/users/johndjs/)
 * (@johndjs)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-widget-logic-randomize-widgets/#post-3024530)
 * Im sorry but can you post the exact code for 3 Widgets ?
 * Thank you
 *  [mbzo2006](https://wordpress.org/support/users/mbzo2006/)
 * (@mbzo2006)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-widget-logic-randomize-widgets/#post-3024640)
 * Sounds interesting idea.
 * Would it be possible to use this technique to alternate between two different
   sidebar widgets?
 * For example, two text widgets, A and B:
 * show widget A (hide widget B)
 * else
 * Show Widget B (hide A)
 * Can Widget-Logic already do this?

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

The topic ‘[Plugin: Widget Logic] Randomize Widgets’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/widget-logic_c8dde5.svg)
 * [Widget Logic](https://wordpress.org/plugins/widget-logic/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/widget-logic/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/widget-logic/)
 * [Active Topics](https://wordpress.org/support/plugin/widget-logic/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/widget-logic/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/widget-logic/reviews/)

 * 7 replies
 * 3 participants
 * Last reply from: [mbzo2006](https://wordpress.org/support/users/mbzo2006/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-widget-logic-randomize-widgets/#post-3024640)
 * Status: not resolved