Now that we've got the Loop working in our theme, it's time to start breaking the theme down into template files which will help us make sure edits flow consistently across all of the various aspects of the theme.
My rule of thumb for separating markup and code into its own template file is, first and foremost, avoiding duplicate markup and code. Second, you'll be able to create template files to address any unique markup and code that should only appear in special circumstances, like on a home page, but nowhere else.
The most common template files we'll look at first are the header.php
, footer.php
, and sidebar.php
template files. Each of these template fields will be used in various types of pages on the site.
The header should be the same for an article post page as for a static page. The footer should remain consistent across all types of pages on the site. If I update or change the header or footer, I'll want that change to appear...