Tuesday, June 30, 2015

Refining the Templates

Now that we have added the breadcrumbs, we might be thinking that we do not need it on the home page, just on the sub-pages. As a matter of fact, we likely are thinking that the home page need a completely different structure than the sub-pages.  Looking back at the template hierarchy we can address this easily: https://developer.wordpress.org/themes/basics/template-hierarchy/.

We start by copying index.php to three new files:

  • front-page.php
  • page.php
  • 404.php

On front-page.php, we can delete the breadcrumb block.

On 404.php, we can delete the breadcrumb and "The Loop" block, i.e., the code looping on posts and add a bit about the page not being found.

Because we are not currently using, posts, search, or commenting the index.php file is no longer in use. For completeness, we can change the content of index.php to look like the 404.php file as a catch all.

No comments:

Post a Comment