In wordpress, it calls header.php then whatever template name or the page requested. How can I declare a variable in my php header which I can then refer to in my other tem
I think php session is one of the way to use as a global variable on Wordpress.
1. Functions.php
if(!session_id()) {
session_start();
}
2. Any .php
file where you want set or get global variables
get variable
if(isset($_SESSION['global_var'])) {
$local_var = $_SESSION['global_var'];
}
set variable
$_SESSION['global_var'] = "This is global var";