SlideShare una empresa de Scribd logo
1 de 20
WordPress Template Hierarchy
Jason Yingling
Post vs Page vs Webpage
• Webpage – an HTML document being served
to a web browser. The final output of your
PHP into HTML, CSS, and JS.
Post vs Page vs Webpage
• “post” – content stored in the database in the
wp_posts table
Post vs Page vs Webpage
• Post – A default WordPress post of type “Post”
• Page – A default WordPress post of type
“Page”
• Posts, Pages, and Custom Post Types are all
stored together in the wp_posts table of the
database with different types (Post, Page,
Product, etc.)
Template Terminology
• Template Files – PHP files that determine the site’s
markup.
• Page Templates – “those that apply only to pages to
change their look and feel. A page template can be
applied to a single page, a page section, or a class of
pages.”
• Template Tags – Functions used within template files to
retrieve and return data. (ex. the_title() or
the_content()
• Template Hierarchy – The logic WordPress uses to
determine which template file to use to display certain
data
WordPress as a Factory
• posts – The raw materials
• Database – The warehouse
• WordPress theme – The Assembly Line
• The Browser – The consumer
• https://www.youtube.com/watch?v=nR47WZ
GTywE
Crucial Templates
• style.css – determines the theme’s visual
appearance and registers the theme with
WordPress
• functions.php – used for presentational
functionality.
• Template Files – determine the site’s markup.
Uses PHP to convert data from the database
into the HTML output to the browser.
style.css
• (image of registration header)
• Required by WordPress to register the theme
functions.php
• Enqueuing additional stylesheets and scripts
• Creating widgetized areas and menus
Should only be used for presentational functionality
such as:
• Registering Post Types or Custom Taxonomies
• These should go in a plugin so data is not lost when a
theme is switched.
Should not be used for content functionality such as:
Template Files
• Always used files – files used in every template
– header.php
– footer.php
– sidebar.php (if applicable)
• Additional files – files that may or may not be
used depending on content / hierarchy
– index.php
– single.php
– page.php
– And more
Template Partials
• Allows you to easily reuse code throughout
the theme
• header.php, footer.php, and sidebar.php are
some basic examples
• content.php is commonly used to pull in post
content markup
“A template partial is a piece of a template that is included as
part of another template, such as a site header.”
Common Template Files
• index.php – The main template file. Required in all
themes.
• style.css – The main stylesheet. Required in all themes.
• Header.php – Usually contains site’s doc type, meta
info, stylesheets, etc.
• single.php – used when a visitor requests a single post.
• page.php – used when a visitor requests individual
pages
• Many more descriptions available on the Codex -
https://developer.wordpress.org/themes/basics/templ
ate-files/#common-wordpress-template-files
Template Hierarchy
• The logic WordPress uses to determine which
template file to use to return requested post
data
Everything goes back to index.php
• No single.php template? WordPress will use
index.php
• No page.php template? WordPress will use
index.php
https://developer.wordpress.org/files/2014/10/template-hierarchy.png
Single Post
• single-{post-type}-{slug}.php - (since 4.4) – WP looks
for a specific post. Fox example, single-product-
shirt.php would work for a product post type with the
slug shirt.
• single-{post-type}.php – If the post type of the data is
Product, WordPress would look for single-product.php
• single.php – If the above don’t exist, WordPress then
falls back to single.php
• singular.php – If single.php doesn’t exist, WP looks for
singular.php
• index.php - If none of the above exist WordPress falls
back to index.php
Page
• Custom template file – the page template
assigned to the page
• page-{slug}.php – If the page slug is recent-news,
WordPress looks for page-recent-news.php
• page-{id}.php – If the page ID is 6, WordPress
looks for page-6.php
• page.php
• singular.php
• Index.php
Template Hierarchy Resources
• WordPress Codex image -
https://developer.wordpress.org/files/2014/10/t
emplate-hierarchy.png
• Template Hierarchy in Detail -
https://developer.wordpress.org/themes/basics/t
emplate-hierarchy/#the-template-hierarchy-in-
detail
• Interactive Hierarchy map-
http://wphierarchy.com/
• Show Current Template Plugin -
https://wordpress.org/plugins/show-current-
template
WordPress Template hierarchy

Más contenido relacionado

La actualidad más candente

Castro Chapter 2
Castro Chapter 2Castro Chapter 2
Castro Chapter 2
Jeff Byrnes
 
WordPress as a CMS - Case Study of an Organizational Intranet
WordPress as a CMS - Case Study of an Organizational IntranetWordPress as a CMS - Case Study of an Organizational Intranet
WordPress as a CMS - Case Study of an Organizational Intranet
Tech Liminal
 

La actualidad más candente (20)

The WordPress Way
The WordPress WayThe WordPress Way
The WordPress Way
 
WCBos13 intermediate workshop
WCBos13 intermediate workshopWCBos13 intermediate workshop
WCBos13 intermediate workshop
 
Castro Chapter 2
Castro Chapter 2Castro Chapter 2
Castro Chapter 2
 
WP 101 - Local Development - Themes and Plugins
WP 101 - Local Development - Themes and PluginsWP 101 - Local Development - Themes and Plugins
WP 101 - Local Development - Themes and Plugins
 
Wordpress architecture
Wordpress architectureWordpress architecture
Wordpress architecture
 
Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.
 
Creating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech DayCreating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech Day
 
WP 101 - WordPress Basics
WP 101 - WordPress BasicsWP 101 - WordPress Basics
WP 101 - WordPress Basics
 
WordPress as a CMS
WordPress as a CMSWordPress as a CMS
WordPress as a CMS
 
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon BaltimoreCreating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
 
WordPress Workshop
WordPress WorkshopWordPress Workshop
WordPress Workshop
 
Visual Design for Content Management Systems
Visual Design for Content Management SystemsVisual Design for Content Management Systems
Visual Design for Content Management Systems
 
WordPress Themes 101 - dotEduGuru Summit 2013
WordPress Themes 101 - dotEduGuru Summit 2013WordPress Themes 101 - dotEduGuru Summit 2013
WordPress Themes 101 - dotEduGuru Summit 2013
 
WordPress as a CMS - Case Study of an Organizational Intranet
WordPress as a CMS - Case Study of an Organizational IntranetWordPress as a CMS - Case Study of an Organizational Intranet
WordPress as a CMS - Case Study of an Organizational Intranet
 
Add Custom Post Types to Your WordPress Website
Add Custom Post Types to Your WordPress WebsiteAdd Custom Post Types to Your WordPress Website
Add Custom Post Types to Your WordPress Website
 
WordPress Themes Demystified
WordPress Themes DemystifiedWordPress Themes Demystified
WordPress Themes Demystified
 
Emkane RCC wp qs
Emkane RCC wp qsEmkane RCC wp qs
Emkane RCC wp qs
 
WordPress as a CMS (short version)
WordPress as a CMS (short version)WordPress as a CMS (short version)
WordPress as a CMS (short version)
 
WordPress Themes 101 - HighEdWeb New England 2013
WordPress Themes 101 - HighEdWeb New England 2013WordPress Themes 101 - HighEdWeb New England 2013
WordPress Themes 101 - HighEdWeb New England 2013
 
Design todevelop
Design todevelopDesign todevelop
Design todevelop
 

Similar a WordPress Template hierarchy

How to get your theme in WordPress
How to get your theme in WordPressHow to get your theme in WordPress
How to get your theme in WordPress
Nisha Singh
 
The WordPress University 2012
The WordPress University 2012The WordPress University 2012
The WordPress University 2012
Stephanie Leary
 

Similar a WordPress Template hierarchy (20)

Wordpress template hierarchy
Wordpress template hierarchyWordpress template hierarchy
Wordpress template hierarchy
 
Wordpress theme development
Wordpress theme developmentWordpress theme development
Wordpress theme development
 
Intro to WordPress theme development
Intro to WordPress theme developmentIntro to WordPress theme development
Intro to WordPress theme development
 
Content-Driven WordPress Development - WordCamp Omaha 2014
Content-Driven WordPress Development - WordCamp Omaha 2014Content-Driven WordPress Development - WordCamp Omaha 2014
Content-Driven WordPress Development - WordCamp Omaha 2014
 
Basic word press development
Basic word press developmentBasic word press development
Basic word press development
 
WordPress Theme Workshop: Part 2
WordPress Theme Workshop: Part 2WordPress Theme Workshop: Part 2
WordPress Theme Workshop: Part 2
 
The Flexibility of WordPress
The Flexibility of WordPressThe Flexibility of WordPress
The Flexibility of WordPress
 
How to get your theme in WordPress
How to get your theme in WordPressHow to get your theme in WordPress
How to get your theme in WordPress
 
MCC Web Design Workshop
MCC Web Design WorkshopMCC Web Design Workshop
MCC Web Design Workshop
 
The WordPress University 2012
The WordPress University 2012The WordPress University 2012
The WordPress University 2012
 
Newbies guide to customizing word press themes 25
Newbies guide to customizing word press themes 25Newbies guide to customizing word press themes 25
Newbies guide to customizing word press themes 25
 
Starting WordPress Theme Review
Starting WordPress Theme ReviewStarting WordPress Theme Review
Starting WordPress Theme Review
 
WordPress Theming 101
WordPress Theming 101WordPress Theming 101
WordPress Theming 101
 
MVC Web Application
MVC Web ApplicationMVC Web Application
MVC Web Application
 
Anatomy of a Wordpress theme
Anatomy of a Wordpress themeAnatomy of a Wordpress theme
Anatomy of a Wordpress theme
 
Builing a WordPress Theme
Builing a WordPress ThemeBuiling a WordPress Theme
Builing a WordPress Theme
 
Arizona WP - Building a WordPress Theme
Arizona WP - Building a WordPress ThemeArizona WP - Building a WordPress Theme
Arizona WP - Building a WordPress Theme
 
itPage LDC 09 Presentation
itPage LDC 09 PresentationitPage LDC 09 Presentation
itPage LDC 09 Presentation
 
Websites With Wordpress
Websites With WordpressWebsites With Wordpress
Websites With Wordpress
 
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
 

Más de Jason Yingling

Más de Jason Yingling (13)

WordPress Security Best Practices
WordPress Security Best PracticesWordPress Security Best Practices
WordPress Security Best Practices
 
Installing WP-CLI locally
Installing WP-CLI locallyInstalling WP-CLI locally
Installing WP-CLI locally
 
Getting Started with Gutenberg Development
Getting Started with Gutenberg DevelopmentGetting Started with Gutenberg Development
Getting Started with Gutenberg Development
 
Plugin development
Plugin developmentPlugin development
Plugin development
 
Introducing CSS Grid
Introducing CSS GridIntroducing CSS Grid
Introducing CSS Grid
 
Customizing the WordPress Customizer
Customizing the WordPress CustomizerCustomizing the WordPress Customizer
Customizing the WordPress Customizer
 
Battling Google PageSpeed Insights
Battling Google PageSpeed InsightsBattling Google PageSpeed Insights
Battling Google PageSpeed Insights
 
Putting the Develop in Development
Putting the Develop in Development Putting the Develop in Development
Putting the Develop in Development
 
Getting to Know Underscores
Getting to Know Underscores Getting to Know Underscores
Getting to Know Underscores
 
Speeding Up WordPress sites
Speeding Up WordPress sitesSpeeding Up WordPress sites
Speeding Up WordPress sites
 
Creating Dynamic Sidebars & Widgets in WordPress
Creating Dynamic Sidebars & Widgets in WordPressCreating Dynamic Sidebars & Widgets in WordPress
Creating Dynamic Sidebars & Widgets in WordPress
 
Ithemes presentation
Ithemes presentationIthemes presentation
Ithemes presentation
 
Building Flexible Sites with Advanced Custom Fields
Building Flexible Sites with Advanced Custom FieldsBuilding Flexible Sites with Advanced Custom Fields
Building Flexible Sites with Advanced Custom Fields
 

Último

Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Sheetaleventcompany
 

Último (20)

Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls Dubai
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 

WordPress Template hierarchy

  • 2. Post vs Page vs Webpage • Webpage – an HTML document being served to a web browser. The final output of your PHP into HTML, CSS, and JS.
  • 3. Post vs Page vs Webpage • “post” – content stored in the database in the wp_posts table
  • 4. Post vs Page vs Webpage • Post – A default WordPress post of type “Post” • Page – A default WordPress post of type “Page” • Posts, Pages, and Custom Post Types are all stored together in the wp_posts table of the database with different types (Post, Page, Product, etc.)
  • 5. Template Terminology • Template Files – PHP files that determine the site’s markup. • Page Templates – “those that apply only to pages to change their look and feel. A page template can be applied to a single page, a page section, or a class of pages.” • Template Tags – Functions used within template files to retrieve and return data. (ex. the_title() or the_content() • Template Hierarchy – The logic WordPress uses to determine which template file to use to display certain data
  • 6. WordPress as a Factory • posts – The raw materials • Database – The warehouse • WordPress theme – The Assembly Line • The Browser – The consumer • https://www.youtube.com/watch?v=nR47WZ GTywE
  • 7. Crucial Templates • style.css – determines the theme’s visual appearance and registers the theme with WordPress • functions.php – used for presentational functionality. • Template Files – determine the site’s markup. Uses PHP to convert data from the database into the HTML output to the browser.
  • 8. style.css • (image of registration header) • Required by WordPress to register the theme
  • 9. functions.php • Enqueuing additional stylesheets and scripts • Creating widgetized areas and menus Should only be used for presentational functionality such as: • Registering Post Types or Custom Taxonomies • These should go in a plugin so data is not lost when a theme is switched. Should not be used for content functionality such as:
  • 10. Template Files • Always used files – files used in every template – header.php – footer.php – sidebar.php (if applicable) • Additional files – files that may or may not be used depending on content / hierarchy – index.php – single.php – page.php – And more
  • 11. Template Partials • Allows you to easily reuse code throughout the theme • header.php, footer.php, and sidebar.php are some basic examples • content.php is commonly used to pull in post content markup “A template partial is a piece of a template that is included as part of another template, such as a site header.”
  • 12. Common Template Files • index.php – The main template file. Required in all themes. • style.css – The main stylesheet. Required in all themes. • Header.php – Usually contains site’s doc type, meta info, stylesheets, etc. • single.php – used when a visitor requests a single post. • page.php – used when a visitor requests individual pages • Many more descriptions available on the Codex - https://developer.wordpress.org/themes/basics/templ ate-files/#common-wordpress-template-files
  • 13. Template Hierarchy • The logic WordPress uses to determine which template file to use to return requested post data
  • 14. Everything goes back to index.php • No single.php template? WordPress will use index.php • No page.php template? WordPress will use index.php
  • 16.
  • 17. Single Post • single-{post-type}-{slug}.php - (since 4.4) – WP looks for a specific post. Fox example, single-product- shirt.php would work for a product post type with the slug shirt. • single-{post-type}.php – If the post type of the data is Product, WordPress would look for single-product.php • single.php – If the above don’t exist, WordPress then falls back to single.php • singular.php – If single.php doesn’t exist, WP looks for singular.php • index.php - If none of the above exist WordPress falls back to index.php
  • 18. Page • Custom template file – the page template assigned to the page • page-{slug}.php – If the page slug is recent-news, WordPress looks for page-recent-news.php • page-{id}.php – If the page ID is 6, WordPress looks for page-6.php • page.php • singular.php • Index.php
  • 19. Template Hierarchy Resources • WordPress Codex image - https://developer.wordpress.org/files/2014/10/t emplate-hierarchy.png • Template Hierarchy in Detail - https://developer.wordpress.org/themes/basics/t emplate-hierarchy/#the-template-hierarchy-in- detail • Interactive Hierarchy map- http://wphierarchy.com/ • Show Current Template Plugin - https://wordpress.org/plugins/show-current- template