WordPress.org

Ready to get started?Download WordPress

Forums

How can I add a global variable accessible by my theme? (2 posts)

  1. gendem
    Member
    Posted 4 years ago #

    Hi there

    Hopefully a simple question today. I have a theme that I want to set a few global variables in. Specifically, I want to generate a random number between x and y.

    I added the following to functions.php, but it seems not to have worked:

    global $QUOTE_MIN;
    global $QUOTE_MAX;
    
    $QUOTE_MIN=1;
    $QUOTE_MAX=9;

    Is there some other way to achieve this?

    ...Mike

  2. Ryan Hellyer
    Member
    Posted 4 years ago #

    The rand() PHP function can do that:

    http://php.net/manual/en/function.rand.php

Topic Closed

This topic has been closed to new replies.

About this Topic