WordPress Creating a custom template Including header and footer in our template


Example

Let's extend our template from above and include content from header.php and footer.php

Including header:

We will include header right after Template name comment

There are two common ways to do this. Both are right and work same, it's just about your style and how code looks

First way:

<?php
/*
Template Name: Example
*/
get_header();
?>

Second way:

<?php
/*
Template Name: Example
*/
?>
<?php get_header(); ?>

Including footer:

Including footer works the same way, there is only one thing we need to care about, and that is that we include footer after we included header. So the final template should look something like this.

<?php
/*
Template Name: Example
*/
get_header();
?>

<?php get_footer(); ?>