Are you losing the value of your variables when including them in external files? Use relative pathing!
This may help you out, it took me a bit to figure out what was going on here.
I was working on a WordPress theme’s function.php files, and quickly accumulated a lot of code. I wanted to break it down into separate files to make things nice and readable for later. I moved all top level variables into on include files, and guess what… things stopped working!
Here’s the trick, if you use include, make sure you use relative pathing.. for example:
$foo = ‘this is a test’;
This method is going to work, and the variables will be accessable from function.php… now to do this wrong, go a head an absolutely path it. The non-variable bits of the included file will show up, but variable values will be lost.
Here’s what not to do: include(https://my-site.com/myVar.php) or include(get_bloginfo(‘template_url’).’/path’) will also fail.. so beware!