template hierarchy -wordcamp columbus
TRANSCRIPT
July
14
WordPress Template Hierarchy
Presented by Al Davis- WPTeach.com
WordCamp Columbus
Who’s the bald guy?
Toronto WordPress Meetup
WordPress Developers Toronto
Al Davi
s
TELUSSMB ‘Portal God’
WordCamp Developers Toronto
College Professor
WordCamp Toronto
Intro to WordPress
Intro to WordPress Theme and Plugin Development
Freelance DeveloperOwner-wpteach.com
The Question
What file(s) does WordPress use when it displays a certain type of page?
The Answer?
Lets start with the basics
header.php
footer.php
sidebar.php
The Loop
A working theme needs:
index.php + style.css =
A very basic but functional theme
So what is with all of this then?
A: Different looks for different types of content
home.php
Home Page Display Rules 12index.php
front-page.phpThis is used for displaying your latest posts or a static page as defined in Settings > Reading
Front or Home page
3
12Page Display Rules
When you set the Front page in Settings> Reading
Home Page Display RulesWhen posts page is set in the Front Page displays section of Settings> Reading
4
Custom Template FileThe page template assigned to the page<?php/* Template Name: Whatever you call your template*/?>
Page Display Rules
page.php
3
12
page-{slug}.phpif you use the slug “ bananas” WordPress will look for page-bananas.php
page-{id}.phpif the page ID is 4, Wordpress looks to use page-4.php
5index.php
Single Post Page
Singular Page12Static page
Attachment post
Singlular page
Single post
3
12Custom Post
Blog post
4
MIME-type.phpIt can be any MIME type ( video.php, image.php, etc) for text/plain in order:1.text.php2.plain.php3.text_plain.php
Singular Post
single.php
Single Post- Attachment 3
12attachment.php
single-attachment.php
5index.php
single-{posttype}.phpif post type was “movies”, WordPress would look for single-movies.php
Singular Post single.php
Single Post- Custom Post
3
12
index.php
single-post.php
Singular Post single.php
Single Post- Blog Post
3
12
index.php
4
Custom Template FileThe page template assigned to the page<?php/* Template Name: Whatever you call your template*/?>
Singular Page
page.php
3
12
page-{slug}.phpif you use the slug “ bananas” WordPress will look for page-bananas.php
page-{id}.phpif the page ID is 4, Wordpress looks to use page-4.php
5index.php
Static page-aka
“ Page Display Rules”
Post Pages
Category PagesTag PagesCustom Post Types
Archive Pages
Date Pages3
1
2Author Pages
Category Pages Tag Pages Author Pages Date Pages
4
3
1
2
5
1tag-{slug}.php
tag-{id}.php
tag.php
archive.php
index.php
4
3
2
5
1category-{slug}.phpcategory-{id}.php
category.php
archive.php
index.php
4
3
2
5
1author-{nicename}.phpauthor-{id}.php
author.php
archive.php
index.php
3
2
1date.php
archive.php
index.php
Custom Post Type Pages
3
2
1archive-{post-type}.php
archive.php
index.php
Category Pages from Tag Pages
Why learn this?Category from Category
Differentiate Content Types
3
12
Category from Pages
4 Pages
uestions?Q