This question is regarding wordpress.
I have two variables $random_n and $adcount declared in each of index.php , archieve.php, search.php and single.php files at the very first line.
The variables are declared as follows:
<?php $random_n = randomNumber();?>
<?php $adcount = 1; ?>
randomNumber() is a function inside function.php.
If I move those variables to header.php and remove them from all these files, it stops working. :/ The variables can’t be found in index.php, archieve.php, search.php, single.php if they are placed in header.php
I’ve also tried putting this code inside a new file and including that file to index.php, archieve.php, search.php, and single.php, but it hadn’t helped as well.
If the variable is somehow related to your blog configuration, you should use the wordpress option API to build this (see here , search for option).
If your variable is random (your function name hints that) a way to work around this would be using session variables to store those values.
A good tutorial on how to use session variables in wordpress can be found here:
http://www.myguysolutions.com/2010/04/14/how-to-enable-the-use-of-sessions-on-your-wordpress-blog/