We create our page.php
template file by copying index.php
and making some adjustments.
page.php
.index.php
, copy its entire contents, and paste them into page.php
.page.php
, find the code to display the This Month:
heading and delete it:<h2 class="thisMonth embossed" style="color:#fff;">This Month:</h2>
<p class="entry-meta">by <?php the_author_meta('first_name'), ?> <?php the_author_meta('last_name'), ?> in <?php the_category(", ") ?></p>
Read more
link and the comments count and delete that:<p class="left"><a class="more" href="<?php the_permalink() ?>">Read more »</a></p> <p class="right"><a class="comments-count" href="<?php the_permalink() ?>"><?php comments_number("0", "1", '%') ?></a></p>
page.php
and refresh your browser.We created a new file called page.php
to display static pages, and edited it to remove any content we don't need on those pages.
Now the About us page looks like the screenshot below:
Much better—the metadata has gone, as well as the Read more link, the comments count, and the confusing heading.
In Chapter 4, Advanced Theme Features, we'll look at doing more with page templates, for example, creating a template that doesn't display a sidebar.
Q1. According to the WordPress hierarchy, which of the following is true and which is false?
page.php
trumps index.php
when viewing a static pagearchive.php
trumps category.php
when viewing a category archivesingle.php
trumps index.php
when viewing a static pageQ2. What does the header.php
file contain?
<head>
tag and its contents<header>
tag and its contents, taken from the theme designDOCTYPE
to the end of the <header>
tagQ3. Which files normally include widgets?
footer.php
sidebar.php
header.php