This is regarding
I've two variables
$adcount declared in every of
single.php files at the beginning line.
The variables are declared the following:
<?php $random_n = randomNumber();?> <?php $adcount = 1; ?>
randomNumber() is really a function inside function.php.
Basically move individuals variables to
header.php and take away them all these files, it reduces. :/ The variables can not be present in
single.php if they're put into
I have also attempted putting this code in the new file and including that file to
single.php, however it had not assisted too.
var_dump($random_n) into the start of
index.php and publish the output, please.
One possible reason is your
search and so forth are incorporated within the function that doesn't share the scope with
header.php, so that your vars are simply outdoors from the scope. It could help should you declare them
header.php as well as your working files. But that is not recommended.
Better solution is always to introduce some
Registry object (Registry pattern) and employ it.
When the variable is in some way associated with your site configuration, you need to use the wordpress option API to construct this (see here , look for option).
In case your variable is random (your function title hints that) a method to deal with this is using session variables to keep individuals values.
A great tutorial regarding how to use session variables in wordpress are available here: http://www.myguysolutions.com/2010/04/14/how-to-enable-the-use-of-sessions-on-your-wordpress-blog/