Viewers: in countries Watching now:
At the beginning of this course, I showed you the WordPress template hierarchy and explained how WordPress figures out what template to use based on the structure. Now we're going to look at index pages, so it's worthwhile to revisit the template hierarchy and see how it handles these index pages. In Underscores, there are three index templates, archive.php, index.php, and search.php. Looking at the template hierarchy, we can see how each of these is used starting with archive.php.
Based on how the visitor interacts with WordPress, a number of different archive indexes can be generated. Most of these are handled by archive.php, unless a more specific template is available. In Underscores, archive.php handles categories, tags, dates, author archives and optional archives for custom post types and taxonomies. That means this single template has to have fallbacks for each of these archive types. We'll see what that looks like a little later in the course.
The next template, index.php, is the default template for WordPress. You can actually make an entire WordPress theme with just three files. Style.css, functions.php, and index.php. As you can see from the hierarchy, everything leads back to index.php. What isn't so obvious from this display is that index.php is the template WordPress uses to display the blog index, which is usually the front page. So when you want to do something with the front page, chances are you want to work with index.php.
The last of the index pages, search.php, is self explanatory. It shows search results. Search results have their own template because we have to account for searches that return no results, and searches that are somehow broken. In addition to these three, there is also a template named 404.php which handles errors. This template appears when the visitor enters or follows a link that goes nowhere. We'll address this template in particular at the end of this chapter. Now that you know what each of these index templates do, it's time to put them to work.
There are currently no FAQs about WordPress: Building Themes from Scratch Using Underscores.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.