WordPress Sage Theme Documentation: Template Structure and Extension Methods

Sage’s theme templates are built on HTML5 Boilerplate and support ARIA roles and the hNews microformat. The files included with the theme can be extended much like a standard WordPress template structure. The main template files in the theme are listed below.

404.php
The 404 error page.
base.php
All template files extend from this file.
index.php
Archive pages such as the blog index, category archives, and author archives.
page.php
Single pages.
single.php
Single post pages.
template-custom.php
An example custom page template.

Below are the content template files included in templates/. Most of our custom work usually happens there.

comments.php
The comments template part.
content-page.php
The content template included by page.php.
content-single.php
The content template included by single.php.
content.php
The content template included by index.php.
entry-meta.php
The metadata template included by content-single.php.
footer.php
The footer template included by base.php.
head.php
The HTML <head> template included by base.php.
header.php
The page header template included by base.php.
page-header.php
The page title/header template used inside pages.
searchform.php
The search form template.
sidebar.php
The sidebar template included by base.php.

Extending Sage templates

Even though Sage wraps theme files in its own way, normal WordPress template hierarchy rules still work. For example:

  • Copy index.php to author.php to create a custom author archive template.
  • Copy index.php to home.php to create a custom blog home page, as long as you have not set a static front page in Reading Settings.
  • Copy index.php to archive-gallery.php to create an archive template for a gallery post type.
  • Copy page.php to front-page.php to create a custom static front page.
  • Copy page.php to page-about.php to create a custom page template for the page whose slug is about.

The wrapper documentation explains in more detail how to create a new base.php file. But if you only need to customize the existing base wrapper, simply copy base.php to base-<template name>.php. You can also use conditional functions in base.php to customize it.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *