[wp-hackers] Page Templates vs Category Templates

Chip Bennett chip at chipbennett.net
Thu Dec 2 00:48:49 UTC 2010

On Wed, Dec 1, 2010 at 5:06 PM, Haluk Karamete <halukkaramete at gmail.com>wrote:

> When you create a Page, you may choose a Page template, right out of
> the box installation of a WordPress. All you need is a few Page
> Templates to exist in the theme folder.

If it's trivial to have "a few Page Templates to exist in the theme folder",
why is not equally trivial to have "category-id.php" and/or
"category-slug.php" templates also in the theme folder?

> Example:
>        SideBar SideBar Content
>        Content SideBar
>        Content SideBar SideBar
>        etc...
> But when you create a category on the admin page, you do not have that
> functionality. That always confused me. Why the lack of that
> functionality from the cat's side?

You don't "have that functionality" for Pages, either, unless the specified
Page templates have already been created. The template-file functionality is
exactly the same for Categories; the difference is only in the UI. With
Pages, a template is selected; with Posts, a Category is selected. In both
cases, the desired template file must already exist in order to be used.

> It is very natural to think that you may have one category to have a
> different look and feel than another one, video stuff for example...
> Of course, one can have the functionality of using a different cat.
> template using the  category-Whatever.php trick.

That's not a "trick"; that's the proper way to define different styles
and/or layouts for different Categories. Why would you call it a "trick"?
It's no more (or less) of a "trick" than creating different Page templates.

> But then, when you
> think about it, "that very way" is also very possible for the pages,
> thanks to the  as Page_Whatever.php trick. But yet, Pages Admin area
> do have the capabilities to select a page template thru a drop down
> conveniently while Category Admin area do not.

How is it less convenient to select a Post Category than it is to select a
Page template? One is a drop-down; the other is a check-box. Both require
one, simple user action.

> I'm curious to find the design  criteria behind that difference...

Pages are stand-alone. Blog Posts are part of a timeline. Pages are (or can
be) hierarchical; Posts are sequential.

Thus, it makes sense for Posts to have an "index", based on time (date
archives) or taxonomy (Category and Tag archives), and for that "index" to
define the style/layout for the Posts that fall into it. Pages, on the other
hand, stand alone entirely, and even their hierarchical relationship only
impacts site navigation. Thus, it makes perfect sense that Pages should be
able to specify their style/layout templates individually.


More information about the wp-hackers mailing list