WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Add random number code to sidebar widget (2 posts)

  1. befree22
    Member
    Posted 1 year ago #

    Could someone tell me how to add code (shown here) to a sidebar widget in WordPress?

    [code]
    $numbers = range(1, 24);
    shuffle($numbers);
    [/code]

    I want the text in the sidebar widget to say "There are __ people on this site."

    The Extended Random Number Generator plugin doesn't work at all. I posted this in the support forum earlier today.

    FYI: The tag [city name] belongs to another plugin.
    FYI: I just downloaded shortcode exec php, tested it but it doesn't seem to work.

  2. befree22
    Member
    Posted 1 year ago #

    Wow! I got the following random number generator php code to work in Shortcode Exec PHP plugin:

    $amountOfDigits = 6;
    $numbers = range(0,9);
    shuffle($numbers);
    
    for($i = 0;$i < $amountOfDigits;$i++)
       $digits .= $numbers[$i];
    
    echo $digits; //prints 217356

    I go the code from http://stackoverflow.com/questions/3140235/php-random-number

Topic Closed

This topic has been closed to new replies.

About this Topic