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
0
470
Template Hierarchy
Intro to the WordPress Template System.
WordCamp Columbus
Caleb Burks
July 17, 2015
Tweet
Share
More Decks by Caleb Burks
See All by Caleb Burks
Child Themes and the Template Hierarchy
wpprodigy
0
160
Contributing to the Theme Review Team
wpprodigy
0
370
Exploring WooCommerce
wpprodigy
0
600
Other Decks in Programming
See All in Programming
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
2
460
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
42 best practices for Symfony, a decade later
tucksaun
1
180
MCP with Cloudflare Workers
yusukebe
2
220
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
170
CSC305 Lecture 25
javiergs
PRO
0
130
nekko cloudにおけるProxmox VE利用事例
irumaru
3
420
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
240
命名をリントする
chiroruxx
1
380
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
630
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
200
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
Featured
See All Featured
A Philosophy of Restraint
colly
203
16k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Making Projects Easy
brettharned
116
5.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
Code Review Best Practice
trishagee
65
17k
It's Worth the Effort
3n
183
28k
How GitHub (no longer) Works
holman
311
140k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Why Our Code Smells
bkeepers
PRO
335
57k
A designer walks into a library…
pauljervisheath
204
24k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
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?