I added a variable to my functions.php file:
$options = get_option( 'simple_options' );
I can access to this variable on every page, but If I call it in the footer.php it's not working. How to fix that?
|
I added a variable to my functions.php file:
I can access to this variable on every page, but If I call it in the footer.php it's not working. How to fix that? |
||||
|
|
|
Generally, you cannot access local variables in a function from outside the function, so this...
would result in "1". To make a global variable, you can do this to make
However, I cannot recommend it, since every other script may change the value. You can use a define:
And in your footer:
But also this wouldn't be that neat, since you'd have to make sure no other script defines this No, your best bet is to get the option just again in your footer. |
|||
|
|