Taking Advantage of Pages
Pages might not seem like they have the sexy versatility of Posts, but believe me, Pages have lots of tricks up their sleeves. Depending on your theme, the pages in your site can be just plain old content or super flexible content containers. How? Through Page Templates, but we’ll save those for the end of this section. First let’s recap what pages are and aren’t.
Remember that pages are content designed to be able to stand alone. They don’t have the inherent connection to each other like posts do. While pages do have a sense of time in terms of when they were published, you can’t (by default) go to a Page archive that lists all the pages in a site, ordered by time. Pages fill a need for content that is outside of the stream of posts (or Custom Post Types) that has its own sense of meaning. Before WordPress Menus were introduced in version 3.0, we used Pages to determine and drive the navigation for the site. Today, Menus allow us to have much more flexible navigation, but Pages still have their own organizational structure that you can leverage in your site to organize content: Page Order and Parent-Child Pages. All the settings for these features are on the right side of the Page Editor (Figure 11.46).
Figure 11.46 Page Attributes.
Using categories (and subcategories), you can get a an idea of a hierarchy of content, but really it’s more a hierarchy of topic. The posts themselves are all at the same hierarchical level. With Pages, you can create a page that is a Parent Page to another, and this defines a clear hierarchy that is reflected in the URLs of the two pages. I created a page called “Hire me” and set its Parent to be “About Tris” (Figure 11.47). When I publish the page, the URL for the new page becomes http://abgwp.trishussey.com/about-tris/hire-me/, and you can see a sense of hierarchy between the two pages (Figure 11.48). But that’s as far as the hierarchy goes for the pages at this point. Unless you manually delete /hire-me/ from the address bar, there isn’t a built-in connection to About Tris. Nor is there any indication on About Tris (not automatically, at least) that there are child pages connected to it. Yes, there is a hierarchy, but it isn’t one that is discernible by default on Pages. Advanced WordPress theme developers can make these connections in the templates for Pages and use them; in practice, though, few people do. There is one way that we look at a list of all the pages on a site, and that is the Pages widget for the sidebar. This is a handy tool and gives us a chance to talk about Page Order.
Figure 11.47 Setting Page parent-child relationships.
Figure 11.48 Page hierarchy (ish).
Page Order is a simple way to list pages in an order you’d like other than by the date. First let’s look at the Page widget and how it works. By putting the Page widget in the sidebar, you can choose to have the pages sorted by Title, Page Order, or Page ID (Figure 11.49). Page ID is essentially order by date, because the ID number of a page (or anything in WordPress) increases by increments. I set the Widget to Page Order and in Figure 11.50, you can see how the Pages are ordered. You can see that Hire Me is a child of About Tris because it is indented below it. Beyond that, this looks like sorting by title. Essentially it is, because all the pages in the list have the same Page Order, 0. I’d like the order to be About, Contact, Blog, Homepage, Front Page; the way to do that is to set the Page Order for the Pages (respectively) 0, 1, 2, 3, 4. I’m going to use the Quick Edit function to set this instead of opening each page in the Editor. This is just a teaser for talking more about managing posts and pages later.
Figure 11.49 Looking at Page Order in a widget.
Figure 11.50 How the widget looks on the site.
From the listing of All Pages, I pass my mouse over the title of the page and click Quick Edit. The area that opens up lets me adjust several things about the page, but not its content. Figure 11.51 shows editing “Blog” and making its page order 2. Page Order counts up from zero, and if pages have the same order number, it then orders them alphabetically. If you have lots of pages, you could have all the ones together, all the twos together, and so on. The result of changing the order of all these pages is in Figure 11.52.
Figure 11.51 Setting the page order for the Blog page.
Figure 11.52 The Page widget on the site with the new order.
Page Order can be applied in several ways by template designers, but for day-to-day WordPress users, this is going to be the most common way they run into them. This leaves the best of the Page tricks for last: Page Templates.
Page Templates is where Pages really get cool. Page Templates can take several parts of WordPress and pull them into one interesting package. Most of the time theme designers include a default Page Template and maybe one that is full width (no sidebars, or in Twenty Eleven’s case, one with sidebars). Some themes include Templates that can list all Posts (in cases where the home page is technically a blog page, but doesn’t display all posts), or like Twenty Eleven, a special home page style that includes a featured Post slider.
Using Page Templates is simple; in the Editor, choose which Template you’d like the page to use (Figure 11.53) and go from there. It’s at this point that I can’t tell you all the various options. I could tell you how to use the Showcase Template in Twenty Eleven, but that won’t help you with the FrontPage Template in Twenty Twelve. Because Page Templates are up to the theme designer, the sky is the limit. I’ve created page templates that have different headers, sidebars, and footers from other posts and pages. I’ve make page templates to load only some posts. You can also create a page template that will list all that page’s child pages (or when on a child page, its parent). There is lots you can do, and it all depends on the theme.
Figure 11.53 Choosing a Page Template.