chrischickenwire
Member
Posted 1 year ago #
Hi there,
I was wondering if it is possible in WordPress to display a different Header.php file and Footer.php depending on which page you're on.
For example, here is my Home page (work in progress)... http://www.rjt-online.com/wp
As you can see the header section uses Javascript and displays the Home Button in white to highlight the page you're on. And the footer says Home.
Now, I have made a Blog page (http://www.rjt-online.com/wp/blog/) and would like a different header and footer for this page (highlighting the Blog button and having Blog in the footer).
I apologise if this is really easy. I'm new to this WordPress thing!
Many thanks,
Chris
chrischickenwire
Member
Posted 1 year ago #
Ok, the next question would be how? I can only seem to figure out how to make the changes to all the pages. How do I make changes to headers/footers/and everything else for that matter for just one page?
canutedechou
Member
Posted 1 year ago #
i use these
at header for example
<?php
if (is_page('contactenos')) {
include(TEMPLATEPATH.'/header-contacto.php');
} elseif (is_page('home')) {
include(TEMPLATEPATH.'/header-home.php.');
} else {
include(TEMPLATEPATH.'/header-default.php');
}
?>
where you set if is a page (is_page) or a post (is_single)
and them you set where is the file
you can use it on footer or headers
chrischickenwire
Member
Posted 1 year ago #
Where abouts in the Header.php should that go? Or should that be the whole code for the Header.php?
canutedechou
Member
Posted 1 year ago #
where the new hader is gonna be included
for example
i have a site where all pages has different headers with different data
so i create a div wich is gonna content all new headers
and inside that div i put this script
and then create all new headers
ready to be included in there
realize that this script detect the page name (or post name) and insert a new data on it
chrischickenwire
Member
Posted 1 year ago #
That's great. I seem to have it working (to an extent).
Is there a way to include for example "if page is Home or a page that has Home as a Parent page, use homeheader.php"?
What would the code be for something like that?
canutedechou
Member
Posted 1 year ago #
mmmm
really dont know
realize that:
if (is_page('contactenos'))
where "contactenos" is the slug name of the page or post
canutedechou
Member
Posted 1 year ago #
i strongly recommend to you
to cal the post and pages with the id
like is_page('4')
coss with this method
you may not have problems in your server