Variable scope across template files
-
I’m having problems with variable scoping in templates and wasn’t able to find a solution in the Codex or the forum here.
I’m trying to find a way — any way — to share a variable between template files. I use a separate file to store a few simple settings for my template (what to show in the sidebar, for example). Because these are used across multiple templates (index.php, single.php, …), I am include_once()ing my options file in header.php. Functions defined this way work fine, but variables are always NULL in other files.
I have tried using
global $xyz;
in both files and even referencing$GLOBALS['xyz']
directly, but no luck.Has anyone run into this problem before?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Variable scope across template files’ is closed to new replies.