Using absolute path instead of get_header to pass variable
-
Hi
I’ve set my theme up so that I can pass a variable to the header.php from index.php inside my theme.
However, reading around it seems that the variable isn’t passed through to the header.php file unless I use an absolute path to it instead of get_header. Example:
Instead of
<?php $bodyid="homepage"; ?> <?php get_header(); ?>I use
<?php $bodyid="homepage"; ?> <?php include ($_SERVER['DOCUMENT_ROOT']. "/wp-content/themes/classicmodified/header.php");?>I’m not great with PHP and this is only my 2nd theme – could anyone tell me if there is any reason why I shouldn’t do this?
The reason for it is I want to pass a body id and page title into the header file so it changes depending on the what page it is on. I think there is another way of doing this using conditional tags but not all my pages need to be wordpressed so I’d like to keep them as static html while getting them to still use the same header file as the wordpress pages.
Thanks in advance!
The topic ‘Using absolute path instead of get_header to pass variable’ is closed to new replies.