This course will be retired on July 6, 2019.
Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
The header.php and footer.php Files2:17 with Zac Gordon
In this video we look at the header and footer files as well as how to call them when needed in other templates.
[SOUND] The header and footer files on a WordPress theme, are very important.
They take all of the code that should be displayed at the top or
at the bottom, of every single page, and abstract amount into single templates.
The header.php and the footer.php.
Over the next couple videos, we're gonna look at the important code that needs to
go in these files, as well as show how to port over
the existing static template pieces, into the header and footer files.
To start off, let's come into our theme and create a new file called,
header.php and footer.php.
In all WordPress sites, we'll need to name our header and
our footer, with this naming convention.
For now, we're just gonna put in some test, text to label each one,
and then we're going to come into our index .php and
open up a code block and call the function get_header.
[SOUND] Add an h1 tag and
then a php block that says get_footer.
[SOUND] We'll go wrap these in paragraph tags as well.
[SOUND] And now let's come over and view our site in the browser.
We could see that we have the header, our index file label and the footer.
What this shows us, is that the header.php file, is called in with, the get_header
function, and the footer.php file, is called in with the get_footer function.
These work in the same way that PHP includes to,
except that these work specifically with these files.
Now that we have these files created,
let's look at how to port over our static template into our dynamic PHP templates.
You need to sign up for Treehouse in order to download course files.Sign up