Page Templates

you learned about the underused post format feature ,
which applies different styles to different types of posts. Pages have an analogous
feature called page templates, which change the way pages look.
Like post formats, page templates are an optional part of a WordPress theme. Your
theme may include multiple page templates or none at all..

When you create a new page, WordPress assumes that you want to use the standard
template. But switching to something else is easy. When you create or edit a page,
choose the template you want from the Template list in the Page Attributes box.
The page template feature faces the same challenge as the post format feature:
Because a theme is designed to suit a variety of sites, and because there’s no way
for a theme to understand the fine details of your site, it can’t provide templates
tailored to your content. The WordPress year themes use page templates for two
basic purposes: to control the appearance of your site’s sidebar, and to create improved
home pages. The following sections explain how to do both.

NOTE There’s one page template you won’t consider in this chapter: the Contributor Page template included with the Twenty Fourteen theme. It’s an unusual but innovative page that automatically gathers and displays author information in a site that has multiple contributors. You’ll try it out when you consider WordPress collaboration.

Pages With or Without Sidebars
With some themes, your site’s sidebar appears on every page, just as it appears
next to every post. With other themes, WordPress displays pages without the sidebar.
No approach suits everyone, and page templates let you change your theme’s
built-in preference.

NOTE If you start adding sidebars to your pages, be consistent. For example,
if you decide not to show sidebars on, say, pages with pictures or photo galleries, make sure the other pages on your site follow suit.
Otherwise, your visitors may feel that your site is unpredictable or poorly organized.

Better Home Pages
Another reason that themes use page templates is to create souped-up home pages.
These specialized pages include a spot for your static content, just like any other
page, along with some extras. The extras can include more widget areas, featured
image sliders, and a customized post list. The goal is to give you a way to create a
more attractive entryway to your site.

Here’s how WordPress assembles a showcase page for the Twenty Eleven theme:
• First, it takes your sticky posts (page 104), and adds them to the Featured
Post gallery. To include a picture alongside a featured post, make sure you set
a featured image (page 190).
• Underneath the Featured Post gallery, WordPress shows the content for the
most recent non-sticky post. If you want WordPress to show only a portion of
the most recent post, you need to use the More quicktag (page 196).
• Underneath that, WordPress lists the titles of the next four most recent posts
(not including sticky posts). To view one, your guest must click its title.
• WordPress adds a sidebar to the left side of the page, next to the list of your
most recent posts. However, this isn’t the standard sidebar you see on your
normal home page (and all the pages that use the sidebar template). Instead,
it’s called the showcase sidebar, and it appears on showcase pages only. To fill
it with widgets, choose AppearanceÆWidgets, and then drag the widgets you
want to the Showcase Sidebar area.

It might occur to you that you like the showcase page, but you want to take the
idea further. For example, maybe you want to control what posts appear in the list
of recent posts, or you want to create several showcase pages that highlight different
categories of posts, like the sections of a newspaper. Unfortunately, showcase
pages don’t give you this flexibility. However, you can begin building a system like
this if you’re running a self-hosted WordPress site and you’re not afraid to get your
hands dirty.

Page Templates

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s