WordPress.org

Forums

Widget Logic
Randomize Widgets (8 posts)

  1. johndjs
    Member
    Posted 2 years ago #

    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/

  2. alanft
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  3. johndjs
    Member
    Posted 2 years ago #

    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.

  4. alanft
    Member
    Plugin Author

    Posted 2 years ago #

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

  5. johndjs
    Member
    Posted 2 years ago #

    No, both widgets just dont appear anywhere now?

    Thanks for trying to help

  6. alanft
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  7. johndjs
    Member
    Posted 2 years ago #

    Im sorry but can you post the exact code for 3 Widgets ?

    Thank you

  8. mbzo2006
    Member
    Posted 2 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.