The header, the footer and the sidebar

Serie WordPress Theme development

Chapter 1. What is a WordPress Theme?
Chapter 2. Creating your own WordPress Theme: Style.css
Chapter 3. The Content: index.php
Chapter 4. The header, the footer and the sidebar

Chapter 4: The header, the footer and the sidebar

DRY – Don’t Repeat Yourself – means don’t repeat code in multiple places, it is a bad method to work. There are three places where you can find reusable components of templates which give the cohesive look and fell and structure. The header, the footer and the sidebar information is the same on all pages.

Header.php
This template file includes the HTML head and the start of the HTML document but also the site logo and navigation. It could include any elements such as secondary navigation or a search area.
You must include wp_head() function into the header template.

functionwp_head() {/**
* Prints scripts or data in the head tag on the front end.
*
* @since 1.5.0
*
/do_action( 'wp_head');}

Footer.php
Everything below the content area should be separated into a footer file. The footer file include whatever you want but most of the times should be contact information, the copyright, navigation options and information relevant to the site.
You must include wp_foot() function into the footer template.

functionwp_footer() {/**
* Prints scripts or data in the head tag on the front end.
*
* @since 1.5.0
*
/do_action( 'wp_footer');}

Sidebar.php
In this case, the information uses to be to the right or to the left of the main content. It should be supporting information on the site. You should have some considerations to take before start working such as how many sidebars are you going to have; are they going to be static or widgetized? The last one enables you to sketch up a site with relative ease and use the Control Panel to place widgets as needed.
You must include wp_sidebar() function into the sidebar template.

function get_sidebar( $name = null ) {
/**
* Fires before the sidebar template file is loaded.
*
* @since 2.2.0
* @since 2.8.0 $name parameter added.
*
* @param string|null $name Name of the specific sidebar file to use. null for the default sidebar.
*/
do_action( 'get_sidebar', $name );