erick_paper
Member
Posted 15 years ago #
Hi. I have some variables in the header.php
of my theme. I imagine that these will be available in the footer.php
of the same theme, given how WP works in a sequence. But they're not available in the footer.php
. What am I missing?
Thanks for any pointers.
erick_paper
Member
Posted 15 years ago #
No. But I tried setting them as global, and they still don't work.
I have a config.php
. I require
it into my header.php
.
All variables inside config.php
are global now. Still footer.php
does not see them.
Any other ideas? Thx for the response!
and are they marked as global in the footer as well? If you've got code in the footer inside functions then you'll need to flag those variables as global there
cafespain
Member
Posted 15 years ago #
- Header.php -
global $myvar;
$myvar = "hello";
- Footer.php -
global $myvar;
echo $myvar;
How are you putting stuff in your footer?
I use footer.php in my mu-plugins
and have this in there:
function wpmu_footer($blah)
{
global $dogooglemap;
$dogooglemap=0;
echo '<link rel="search" type="application/opensearchdescription+xml" title="CanalPlan Blogs" href="http://canalplan.blogdns.com/canalblogs.xml" />';
return $blah;
}
add_action('wp_footer', 'wpmu_footer');
you can also use the php GLOBALS array
so in your config.php file set
$GLOBALS['some_key_name'] = 'your_variable';
then you can access it from anywhere with
$GLOBALS['some_key_name']