As my question suggests I'm having difficulty creating a variable in the header, via functions.php and wp_head, and then calling that variable further down the page.
For example, in functions.php
add_action( 'wp_footer', 'add_ran_var' );
function add_ran_var () {
$random_variable = "1";
}
And before the
</head>
tag include
<?php wp_head(); ?>
in header.php
The problem arises if i try to call $random_variable later on in the page. It returns nothing.
<?php echo $random_variable; ?>
Could anyone please shed some light as to why this does not work? Has it something to do with the order the different files (header.php, functions.php) are called?
Thanks in advance to anyone who can offer me some advice on the above.
Cheers Noel