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
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
800
Other Decks in Programming
See All in Programming
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
130
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
220
The NotImplementedError Problem in Ruby
koic
1
950
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.8k
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
840
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
180
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.5k
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
13
6.3k
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.4k
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
780
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
220
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Making Projects Easy
brettharned
120
6.7k
Between Models and Reality
mayunak
4
350
ラッコキーワード サービス紹介資料
rakko
1
3.7M
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
400
First, design no harm
axbom
PRO
2
1.2k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
Odyssey Design
rkendrick25
PRO
2
710
Rails Girls Zürich Keynote
gr2m
96
14k
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?