In this post we’ll add a header and footer to the theme we created before. This can be done by creating header.php and footer.php files and then calling them by get_header() andget_footer() functions respectively.
Example: Let’s create a header.php file with the following content:
<p> This is header text </p>
And footer.php as follows:
<p> This is footer text </p>
Save both these files in the theme’s root folder (next to index.php). And finally edit index.php to include those “getter” functions as follows:
<h1> <?php bloginfo('name'); ?> </h1>
<p> <?php bloginfo('description'); ?> </p>
<?php get_header(); ?>
<?php
while (have_posts()) {
the_post(); ?>
<h2> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a></h2>
<p> <?php the_content(); ?> </p>
<?php
}
get_footer();
?>
If we load the site’s front page now, it’ll get us the following result:

Moving header and footer in separate files allows us to customise these files independently.