I have included header.php and index.php on the same page.
The following can be found on the header.php file:
<?php
$pageName="home";
if(is_page('47')){
$pageName="services";}
printVar($pageName);
?>
function printVar($v){ //on functions.php
echo $v;
}
It prints out the var immediately after the if-statement and anywhere on header.php, but when I go to index.php it doesn’t print.
<ul class="<?php printVar($pageName); //does not print out ?>">
<li class="home"><a href="/">Home</a></li>
<li class="services"><a href="/">Services</a></li>
<li class="seminar"><a href="#">Seminar</a></li>
<li class="contact last"><a href="#">Contact</a></li>
</ul>
How can I print this variable without moving everything to index.php?
you need to have
in your index.php file
read more about get_header() on wordpress function reference.