Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Template Hierarchy
Search
Caleb Burks
July 17, 2015
Programming
540
0
Share
Template Hierarchy
Intro to the WordPress Template System.
WordCamp Columbus
Caleb Burks
July 17, 2015
More Decks by Caleb Burks
See All by Caleb Burks
Child Themes and the Template Hierarchy
wpprodigy
0
220
Contributing to the Theme Review Team
wpprodigy
0
440
Exploring WooCommerce
wpprodigy
0
790
Other Decks in Programming
See All in Programming
TSKaigi 2026 TypeScriptバックエンドのオブザーバビリティ戦略 — Datadog × NestJSの実践
taiseiyamamotoan
2
280
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
2.7k
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
200
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
440
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
2
310
CSC307 Lecture 17
javiergs
PRO
0
310
AI時代のUIはどこへ行く?その2!
yusukebe
19
6.6k
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
180
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
130
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
110
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
4
1.4k
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
470
Featured
See All Featured
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
How STYLIGHT went responsive
nonsquared
100
6.2k
WCS-LA-2024
lcolladotor
0
620
What's in a price? How to price your products and services
michaelherold
247
13k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.3k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
220
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
Paper Plane
katiecoart
PRO
1
51k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
360
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
Transcript
TEMPLATE HIERARCHY intro to the WordPress template structure
ABOUT ME ▸ Caleb Burks ▸ WC Ninja at Automattic
▸ Loves Gummy Bears ▸ Tweets at @WPprodigy
WHAT'S A TEMPLATE?
None
HOW DOES THE HIERARCHY WORK?
REQUIREMENTS TO BE A THEME ▸ style.css ▸ index.php
STYLE.CSS /* Theme Name: My Theme Theme URI: http://awesometheme.com Author:
Caleb Burks Author URI: http://author.com Description: Blah Blah License: GNU General Public License v3 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Text Domain: storefront */
MAIN TEMPLATES: INDEX ▸ home.php - blog homepage ▸ index.php
- backup for home.php
INDEX EXAMPLE
MAIN TEMPLATES: POSTS ▸ single.php - Single Post Page ▸
singular.php - Fallback (new)
MAIN TEMPLATES: PAGE ▸ front-page.php - static homepage ▸ page.php
- backup for front-page.php ▸ singular.php - Fallback (new)
AREN'T THERE MORE PARTS?
COMPONENTIZED TEMPLATES ▸ get_header() ▸ get_footer() ▸ get_sidebar()
HEADER.PHP ▸ wp_head() ▸ wp_title() ▸ body_class()
FOOTER.PHP ▸ wp_footer() ▸ date(‘Y’)
SIDEBAR.PHP ▸ dynamic_sidebar()
A CLOSER LOOK
None
INCLUDING TEMPLATES get_template_part(); This is essentially a PHP include or
require, on steroids.
CONTENT.PHP Used for posts in the index pages. ▸ the_title()
▸ the_content() ▸ the_excerpt()
OTHER CONTENT TEMPLATE PARTS content-single.php for single posts. content-page.php for
single pages. content-search.php for results from searches.
BLOG TEMPLATES ▸ index.php or home.php ▸ content.php
SINGLE TEMPLATES ▸ single.php for single posts ▸ page.php for
single pages
BUT WAIT, THERE'S MORE!
ARCHIVE TEMPLATES ▸ Categories ▸ Tags ▸ Date-Based ▸ Author-Based
ARCHIVE.PHP Used for displaying archive pages ▸ date.php ▸ category.php
▸ taxonomy.php ▸ tag.php ▸ author.php
COMMENTS.PHP ▸ Author comment highlighting ▸ Display gravatars if appropriate
▸ Support threaded comments
SEARCH.PHP Displays a list of posts/pages based on search query.
▸ Include the search form again ▸ get_search_form()
CUSTOM TEMPLATES
CUSTOM TEMPLATES: ARCHIVES ▸ category-$slug.php ▸ category-$id.php ▸ tag-$slug.php ▸
tag-$id.php Applies to authors, taxonimies, and CPT's as well.
CUSTOM TEMPLATES: POSTS <?php get_template_part( 'content', get_post_format() ); ?> https://codex.wordpress.org/Post_Formats
Example: content-video.php
CUSTOM TEMPLATES: PAGES ▸ page-$slug.php ▸ page-$id.php OR...
CUSTOM TEMPLATES: PAGES
CUSTOM TEMPLATES: PAGES Make your own template with just one
extra line of code!
CUSTOM TEMPLATES: PAGES How to create a custom home page
template: 1. Copy page.php 2. Rename it to page-home.php 3. Add the following comment to the top: 4. Template Name: Homepage
CONFUSED YET?
AWESOME TOOLS ▸ What The File https://wordpress.org/plugins/what-the- file/
AWESOME TOOLS ▸ WPhierarchy.com
AWESOME TOOLS ▸ _s underscores.com
QUESTIONS?