WordPress Theme variables scope
<p>I need to create a variable that can be accessed throughout my WordPress Theme template files  (index.php, header.php etc..). I know function definitions go inside the <code>functions.php</code> template file (in your theme path), but there's no such thing for variables.</p>

<p>For example I constantly need to retrieve Categories in my Theme, so I would like to have this accessible from anywhere in my theme:</p>

<p><code>$categories = get_categories(); /* get_categories() is a wordpress function */ </code></p>

<p>This way I can simply access to allocated data, without having to re-allocate it every time I need to get my categories.</p>

<p>Unfortunately adding that piece of code in my <code>functions.php</code> file, doesn't work, neither does making the variable <code>global</code>.</p>
