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

Changing Your Home Page

If the list of posts is less important on your site, or if you
want to show some sort of welcome message, or if you just want to direct traffic (in
other words, give readers the option of reading posts or going elsewhere on your
site), it makes sense to start by showing a page instead of a post.

Creating a Brochure Site

The simplest way to change your home page is to ditch the post system altogether,
using pages instead of posts throughout your site. The resulting all-pages site is
sometimes called a brochure site, because it resembles the sort of informational
pamphlet you might pick up in a store.

Should You Build a Brochure Site?
A brochure site may make sense if you’re building a small site
with very simple content. The restaurant site in Figure 7-17 is
one example.
But if you’re trying to decide between a brochure site and a
post-based site, consider two questions. First, would your site
be more attractive to readers if you included posts? Even the
bare-bones restaurant site might be more interesting with
posts that chronicle restaurant news, menu experiments,
and special events. Not only that, but the fact that posts are
frequent, dated, and personal makes the site more vibrant. In
addition, if you want to get people talking on your site—for
example, posting comments about recent meals or sending in
requests and off-the-wall recipe ideas—you’ll have more luck
if you include posts. Think of it this way: A brochure site feels
like a statement, while a blog feels like a constantly unfolding
conversation.
Then again, you may decide that a brochure site is exactly
what you want. Maybe you really don’t have time to spend
updating and maintaining a site, so you simply want a place
to publish some basic information on the Web and leave it at
that. You can still take advantage of several of WordPress’s
best features, like themes, which ensure that your pages look
consistent. You’ll also get WordPress’s help if you want to track
visitors (page 444), add sharing buttons (page 412), or add any
one of a number of features described in this book.

TIP If you use a custom page for your home page, you may want to jazz it up with a few more navigational
features. Many themes provide page templates that can help you out by adding a widget-stocked sidebar beside
your page content,

Creating a Custom Entry Page

Even if you want to change your home page, you might not want to ditch the post
system. In such a case, use a static home page (called a welcome page), and include
a full complement of posts on another page.
The trick to doing this is specifying a URL for the page that displays your posts.
Here’s where things get slightly bizarre. To get the URL for your posts, you create
yet another page. This page is just a placeholder—its sole purpose is to provide the
web address for the posts page. You don’t actually need to put any content on this
page, because WordPress automatically creates the list of posts.

NOTE If you use the self-hosted version of WordPress, you need to make sure you changed your site’s
permalink setting to use post titles rather than post IDs (page 117). Otherwise, the link to your placeholder page
will use the post’s ID, not its name. This is terribly confusing—it means you’ll end up with a permalink with a
name like http://magicteahouse.net/?p=583 that actually shows your list of posts.

Even though you created a posts page, that doesn’t mean your visitors know
about it. They need a way to get there, and the best option is a link in your site’s
menu. Creating that is easy—you simply add a new menu item that points to
your placeholder page.

In some cases, you may decide not to lump all your posts together in a single reverse chronological
stream. In that case, you don’t need to create the placeholder page.
Instead, you can add category links to your menu so that visitors browse all the
posts that fall into a particular category.
This is a great approach, but it may become less practical if you have a lot of categories,
because you don’t want to burden your site with a crowded, clumsy menu.
One solution—provided you have a self-hosted site—is to customize your home page
with the theme-editing tricks

Changing Your Home Page

Ordering Pages

Often, when you display a list of pages, you want to dictate which ones show up
first and which ones are last. You can do this by typing in a number for the Order
setting, which appears in the Page Attributes box when you create (or edit) a page.
The Order setting affects the order of your pages in two situations: when you display
pages in an automatic menu and when you display them in the Pages widget with
the “Sort by” box set to “Page order.”
Ordinarily, WordPress sets the order number of every page to 0. Technically, that
means that each page is tied for first position, and the page order setting has no
effect. But if you want to set the order (say you want “Our Story” followed by “Our
Location” followed by “Contact Us”), you’d assign these pages steadily increasing
page-order numbers (say, 0, 1, and 2). The actual numbers don’t really matter—the
important thing is how they compare. WordPress always displays larger-numbered
pages toward the bottom of the list or on the right end of a horizontal menu, with
smaller-numbered pages closer to the top of a list or to the left of a menu bar. If two
or more pages have the same order value, WordPress orders them alphabetically.

TIP If you rearrange a bunch of pages, you need to change their page-order values. The easiest way to do
that is to go to the Pages list (choose Pages→All Pages), point to a post, and click the Quick Edit link. This way,
you can quickly modify some page information, including the order, without opening the whole page for editing.
There’s another way to group pages: You can designate some as child pages that
belong to a specific parent page. (You may have used this type of organization
before, to create subcategories for your posts.) To create
this hierarchy, you set the Parent setting in the Pages Attribute box when you
create or edit the page.

The order settings create the nicely styled menu and nested list .
The menu displays subsidiary pages in submenus, while the Pages widget slightly
indents nested pages.

Life can get a bit confusing when you order and group pages. Just remember that
when WordPress orders pages, it compares only the pages at the same level. For
example, you can use the page order to adjust the position of the Assault Charges,
Drug Offenses, Family Law, and Personal Injury Defense pages with respect to one
another. However, WordPress won’t compare the order values of the Family Law
and Legal Disclaimers pages, because they aren’t at the same level and won’t ever
be shown next to each other.

Ordering Pages

Showing Pages in a Menu

Most themes start out with a menu. In fact, menus are considered so important to
the average WordPress site that most themes don’t let you remove the menu.

When you create a new WordPress site, it starts out with an automatic menu, so
named because WordPress creates it automatically.

every time you add a new page, like the “About the Practice”
page shown earlier, WordPress adds a matching link in the menu. It keeps the links
ordered alphabetically by page name.

You can exert more control over how your theme arranges the page links in a menu,
in one of two ways: You can use the ordering and grouping features described next,
or you can create a custom menu.

The ordering and grouping approach
works best if you just want to adjust the position of a few commands in the automatic
menu but you’re happy letting WordPress run the show. By comparison, custom
menus take slightly more work but pay off with far more flexibility and extra features.

Showing Pages in a Menu

Showing Pages in the Pages Widget

The Pages widget displays a simple list of links (Figure 7-5). Like any other widget,
you can place it anywhere on your home page, such as in a sidebar. Choose
Appearance→Widgets and then drag the widget where you want it.

Use the Exclude Box Sparingly

It might occur to you that you could add several Pages widgets
to different parts of your home page, each of which shows a
different subset of pages. That’s an interesting idea, but a bad
one, because of the way the exclusion list works.
If you use the Pages widget to create three page lists, for example,
every time you add a new page that you want to leave
off the lists, you need to add the page to the exclusion list of
each menu. That extra work can cause a serious headache. To
avoid this, use the Pages widget only when you want to show
most or all of your pages. If you want to show a smaller group
of just a few pages, create a custom menu and show it with the
Custom Menu widget.

The Pages widget also lets you sort your list of pages. You set the sort order using
the drop-down list in the “Sort by” box. Ordinarily, the order is “Page title,” which
means that WordPress organizes your pages alphabetically by title. Alternatively, you
can choose “Page ID,” and WordPress lists pages from oldest to newest (because
newer pages always get higher ID numbers). Lastly, you can choose “Page order,”
which lets you pick the order

Showing Pages in the Pages Widget

PAGES

WordPress has another, complementary way to showcase content, called pages.
Unlike posts, pages aren’t dated, categorized, or tagged. They exist independently
of posts. The easiest way to understand the role of WordPress pages is to think of
them as ordinary web pages, like the kind you might compose in an HTML editor

NOTE Pages don’t have categories and tags, they aren’t listed in chronological order, and you can’t browse
them by date. However, they still have some WordPress smarts. Most notably, they get their formatting instructions
from WordPress themes, just like every other part of your site. In most themes, a basic page looks a lot like
a basic post—for example, both use the same fonts for their title and text.

Understanding Pages

Why do some people call pages “static pages”?
Although WordPress calls this feature pages, many webheads
find that confusing. After all, isn’t a page anything you view on
the Web with a browser? And don’t posts appear in web pages?
For these reasons, WordPress experts—and WordPress itself,
sometimes—often use a different term. They call WordPress
pages static pages. Sadly, this term is almost as confusing.
It stems from the old days of the Web, when designers distinguished
between dynamic pages that could do incredible
feats with the help of code, and static pages that showed fixed,
unchanging content. That fits with the way most people use
WordPress pages—they create them, fill them with content,
and then publish them.
However, WordPress pages aren’t really static—they do change.
Flip your blog over to a different theme, and all your posts
and pages update seamlessly to match the new style. That’s
because WordPress stores all the content for your pages—as
well as the content for the rest of your site, including posts—in
its database. And, finally, a static page changes anytime you
decide to edit it.
If you’re still confused, here’s the bottom line: A WordPress
site can hold both posts and pages, and you create, format,
and manage them in much the same way. The key difference
is that WordPress automatically dates, orders, and groups
posts. WordPress also puts them on the home page and
assumes that people will want to read them from newest to
oldest. From WordPress’s point of view, posts are the lead
actors on your site, while pages are supporting characters.
But you’re not bound by that narrow definition of a site

How do your guests visit pages?

Like posts, every page gets a unique web address (URL), called a permalink.

.Of course, your readers aren’t likely to type in any URL other than the address for
your home page, so you need to provide links so visitors can get to your pages.
One way to do this is by putting links in posts and pages so you can connect them
together.

Links are a decent way to join related posts and pages, but they aren’t much help if
a guest wants to browse the pages on your site. That’s not a problem with posts—if
your visitors want to read posts, they can browse them easily on the home page,
starting with the most recent one and moving back in time. Or they can browse posts
in a specific category or with a specific tag (page 123). But WordPress doesn’t put
pages in chronological order, feature them on the home page, or give them category
or tag information. Visitors can find pages through a keyword search (by typing
something into the search box and then pressing the Enter key), because searches
scan the content in both posts and pages. But guessing at keywords is a clumsy
way to find a page, and it’s no substitute for a more convenient navigation system.
Fortunately, WordPress has several better, ready-made solutions to help visitors
find your pages:

The Pages widget. Add this to your page, and visitors will always see a list of
all your pages, in the order you want. This widget works best if you want to
highlight all (or almost all) of your pages.

An automatic menu. Many themes automatically put all your pages in a menu
on the home page. The only problem is that this auto-generated menu includes
every page in your site. If that results in an overly cluttered or disorganized
menu, you’ll prefer the next option.

A custom menu. You pick the pages you want to showcase and arrange them
just so. You then display the menu somewhere prominent on your home page
(often where the automatic menu used to go). Most people take this route.

PAGES