0

Is there a common naming convention for page templates?

Most themes have a two sidebars:

Primary, Secondary

And then if I'm not mistaken, these combinations:

Page templates:

  • 1 Sidebar, Primary Right
  • 1 Sidebar, Primary Left
  • 2 Sidebar, Primary, Secondary Right
  • 2 Sidebar, Primary, Secondary Left
  • 2 Sidebar, Primary, Content, Secondary

Is there a fairly user friendly, compact naming convention that is easily understood? I'd love to know!

1 Answer 1

1

Templates in general have a strict naming convention according to the Template Hierarchy, regardless of sidebars included or not. Wordpress uses template names according to this hierarchy to decide what template should be dished up for the specific page being viewed. Any template not following this naming conventions set out by the template hierarchy is simply ignored by default

However, when it comes to page templates, the playing field is quite open and no real naming convention exists in naming them. Before the release of Wordpress v3.4, all page templates had to be called page-xxx.php where xxx was your custom naming convention. In v3.4 things changed in that you can now name a page template what you want without the page prefix, keeping in mind that you don't use prefixes used by the template hierarchy like archive or category. You can check out this great answer by @ChipBennet for an explanation how this works

The general rule is to make use of descriptive names (This is also true for naming functions, classes, widgets, sidebars and variables). Name the template specific to what it is used for, or in this case the position of the sidebar or what sidebar is used in the specific page template. Your naming convention should be as clear to yourself and others as possible and the name should speak for itself and should not be confusing.

Just take a look at the bundled theme, twentyfourteen. It has two dedicated page templates called full-width.php and contributors.php. The names of these templates are self explanatory.

Touching on the naming of sidebars, I always give my sidebars descriptive names like main-sidebar, footer-sidebar-1 and advertising-sidebar so I exactly know what and where they are used, and even if you get hold of my theme you will know exactly just from the name where that specific sidebar is used

TO CONCLUDE:

Is there a fairly user friendly, compact naming convention that is easily understood?

Always stick with descriptive names that can be easily understood by a wide audience, even to new-comers to Wordpress. This should not only go for page templates and sidebar names, but for any naming convention not specifically mentioned in the template hierarchy and the naming convention section in the coding standards.

Remember, one forgets, so in 5 years time, you and the person who is using your theme, will still know that when they see a template called full-width.php, it means it is a template used to display a full width page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.