Commonly Useful Page Templates

I find on nearly every one of the many, many WordPress powered sites I take care of, I have at least a couple of special page templates that I set up and use frequently.


No Title

Sometimes it’s nice to have a page template available that doesn’t spit out the title at the top. I am an avid user of Wufoo forms, which inherently have their own titles. It can be awkward to have a page like “Contact Website” which has the regular page title at the top, then a Wufoo title right below it. It is possible to suppress a Wufoo title (see our contact form), but I find it easier and more flexible to suppress the WordPress title instead (generally).

With Comments

The most common use for pages is for “static” content. Things that aren’t as timely, chronological, or conversational as blog posts. Things like an About page or Contact page are very common uses for Pages. So it’s likely the default page template does not include commenting. That is a choice though, not something that is forced in any way by WordPress. I find it useful to have a page template identical to the default page template only with the comments code included.

Remember that Pages don’t go out to the RSS feed, so this could potentially be used for something like content only for visitors of the website (that also needs discussion).


Through a trivially simple setting (Settings > Reading) you can change the homepage of your site to use a specific Page. If the homepage of your site is going to be unique in it’s design/layout to other internal pages, you may want to set up a special page template just for it. It can be a quite liberating feeling to know you have a special file you can tinker with for the homepage without worry of affecting other pages.

No Sidebar

Sidebars are often loaded with ancillary content. Stuff that is related to the website, but probably not related to the specific content inside the Page. As such, it may be distracting and it may be a good idea to have the option to use a template that does not include the sidebar. Another good reason? Width. Some pages may just call for that extra few hundred pixels and now you’ll have to power to accommodate.

Another Way it Could Be Done (Smarter?)

Above are four different examples, all very real page templates that come from my day-to-day use of WordPress across many different sites. But that makes four separate files, five if you include the default page template which is almost surely in use. These files are really only trivially different. A deleted line of code here, a few extra lines there. Does that really necessitate have 5 separate template files?

It may or may not… it depends on how different those templates are. Sometimes it can feel nice knowing you have separate files like that for fine-grained control. Sometimes it can feel like a burden and a slap in the face of the spirit of templateing.

Here is another possibility… use custom fields!

The theory here is that you would use only one page template, but that template would check for the existence of some special custom fields before building it’s various parts.

In the part of our page template that displays the sidebar with get_sidebar();, we’ll wrap it like this instead:

    if (!get_post_meta($post->ID, "noSidebar", true)) {

Then in order to remove the sidebar from a page, we can use the same template all the other pages use only set the specific custom field like this:

As I mentioned above, there are pros and cons to this. Having only one smart template is appealing for code efficiency (DRY! Don’t Repeat Yourself!), but this is mingling “design” and “content” (custom fields being content), which isn’t ideal. Oh internet, you are always so full of conundrums.


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s