Reputation: 2224
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
?
Upvotes: 0
Views: 121
Reputation: 7592
you need to have
<?php get_header(); ?>
in your index.php file
read more about get_header() on wordpress function reference.
Upvotes: 2
Reputation: 322
Try adding:
include("header.php");
include("functions.php");
to your index.php
Add:
include("header.php");
in functions.php
and add:
include("functions.php");
in header.php
Upvotes: 1