SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
WordPress Theme
Workshop: Part 2
November 4th, 2017
David Bisset
davidbisset.com / @dimensionmedia
What Makes A WordPress Theme
The REALLY minimum WordPress theme.
What Makes A WordPress Theme
The REALLY minimum WordPress theme.
What Makes A WordPress Theme
More Common To See
What You REALLY Need
While index.php and a style.css file technically
are all you need, in reality most minimum
themes need the following:
• header.php
• footer.php
• index.php
• style.css
• functions.php
Theme Folder And Structure
Twenty Seventeen Theme
organizes its file structure
like this…
Up to you how to organize.
WordPress doesn’t require
folders. Best to see what
other major themes use.
Stick with a common
structure.
Common Files
header.php - This file will contain the code for the header section of the theme;
index.php - This is the main file for the theme. It will contain the code for the Main
Area and will specify where the other files will be included;
sidebar.php - This file will contain the information about the sidebar;
footer.php - This file will handle your footer;
style.css - This file will handle the styling of your new theme;
Template Hierarchy
header.php - This file will contain the code for the header section of the theme;
index.php - This is the main file for the theme. It will contain the code for the Main
Area and will specify where the other files will be included;
sidebar.php - This file will contain the information about the sidebar;
footer.php - This file will handle your footer;
style.css - This file will handle the styling of your new theme;
https://developer.wordpress.org/files/2014/10/template-hierarchy.png https://developer.wordpress.org/themes/basics/template-hierarchy/
Template Hierarchy
Home Page
By default,WordPress sets your site’s home page to
display your latest blog posts.This page is called the blog
posts index.You can also set your blog posts to display on
a separate static page.The template file home.php is used
to render the blog posts index, whether it is being used
as the front page or on separate static page. If home.php
does not exist,WordPress will use index.php.
• home.php
• index.php
Front Page Display
The front-page.php template file is used to render your
site’s front page, whether the front page displays the blog
posts index (mentioned before) or a static page.
• front-page.php – Used for both “your latest posts” or “a static page” as set in the
front page displays section of Settings → Reading.
• home.php – If WordPress cannot find front-page.php and “your latest posts” is set
in the front page displays section, it will look for home.php. Additionally,
WordPress will look for this file when the posts page is set in the front page
displays section.
• page.php – When “front page” is set in the front page displays section.
• index.php
Single Post
The single post template file is used to render
a single post.
• single-{post-type}-{slug}.php – (Since 4.4) First,WordPress looks for
a template for the specific post. For example, if post type is product
and the post slug is dmc-12,WordPress would look for single-
product-dmc-12.php.
• single-{post-type}.php – If the post type is product,WordPress
would look for single-product.php.
• single.php – WordPress then falls back to single.php.
• index.php
Single Page
The single post template file is used to render
a single page.
• custom template file – The page template assigned to the page.
get_page_templates().
• page-{slug}.php – If the page slug is recent-news,WordPress will
look to use page-recent-news.php.
• page-{id}.php – If the page ID is 6,WordPress will look to use
page-6.php.
• page.php
• singular.php
• index.php
Category
Rendering category archive index pages uses the
following path in WordPress:
• category-{slug}.php – If the category’s slug is news,WordPress will
look for category-news.php.
• category-{id}.php – If the category’s ID is 6,WordPress will look for
category-6.php.
• category.php
• archive.php
• index.php
Tags
To display a tag archive index page,WordPress uses the
following path:
• tag-{slug}.php – If the tag’s slug is sometag,WordPress will look for
tag-sometag.php.
• tag-{id}.php – If the tag’s ID is 6,WordPress will look for tag-6.php.
• tag.php
• archive.php
• index.php
Custom Taxonomies
Custom taxonomies use a slightly different template file
path:
• taxonomy-{taxonomy}-{term}.php – If the taxonomy is sometax,
and taxonomy’s term is someterm,WordPress will look for
taxonomy-sometax-someterm.php. In the case of post formats, the
taxonomy is ‘post_format’ and the terms are ‘post-format-{format}.
i.e. taxonomy-post_format-post-format-link.php for the link post
format.
• taxonomy-{taxonomy}.php – If the taxonomy were sometax,
WordPress would look for taxonomy-sometax.php.
• taxonomy.php
• archive.php
• index.php
Custom Post Types
Custom Post Types use the following path to render the
appropriate archive index page.
• archive-{post_type}.php – If the post type is product,WordPress
will look for archive-product.php.
• archive.php
• index.php
Author Pages
Starting To See A Pattern? :-)
• author-{nicename}.php – If the author’s nice name is matt,
WordPress will look for author-matt.php.
• author-{id}.php – If the author’s ID were 6,WordPress will look for
author-6.php.
• author.php
• archive.php
• index.php
404 Template
Seriously,AreYou Starting To See A Pattern? :-)
• 404.php
• index.php
styles.css
The style.css is a stylesheet (CSS) file required for every WordPress theme.
/*
Theme Name: Twenty Seventeen
Theme URI: https://wordpress.org/themes/twentyseventeen/
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Twenty Seventeen brings your site to life with immersive
featured images and subtle animations. With a focus on business sites,
it features multiple sections on the front page as well as widgets,
navigation and social menus, a logo, and more. Personalize its
asymmetrical grid with a custom color scheme and showcase your
multimedia content with post formats. Our default theme for 2017 works
great in many languages, for any abilities, and on any device.
Version: 1.0
*/
https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/
styles.css (child theme version)
The style.css is a stylesheet (CSS) file required for every WordPress theme.
/*
Theme Name: Twenty Seventeen Child Theme
Template: Twenty Seventeen
*/
https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/
functions.php
The functions.php file is where you add unique features to your WordPress theme. Not
required but nearly EVERY theme as one.
Behaves like a WordPress plugin, adding features and functionality to a WordPress site.
You can use it to call WordPress functions and to define your own functions.
https://developer.wordpress.org/themes/basics/theme-functions/
<?php
/**
* Enqueue scripts and styles.
*/
function testme_scripts() {
wp_enqueue_style( 'testme-style', get_stylesheet_uri() );
wp_enqueue_script( 'testme-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( 'testme-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(),
'20151215', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'testme_scripts' );
_s Starter Theme
http://underscores.me/

Contenu connexe

Tendances

Theme development essentials columbus oh word camp 2012
Theme development essentials   columbus oh word camp 2012Theme development essentials   columbus oh word camp 2012
Theme development essentials columbus oh word camp 2012
Joe Querin
 

Tendances (20)

WordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
 
WordPress Theme Development Basics
WordPress Theme Development BasicsWordPress Theme Development Basics
WordPress Theme Development Basics
 
Starting WordPress Theme Review
Starting WordPress Theme ReviewStarting WordPress Theme Review
Starting WordPress Theme Review
 
Wordpress template hierarchy
Wordpress template hierarchyWordpress template hierarchy
Wordpress template hierarchy
 
MCC Web Design Workshop
MCC Web Design WorkshopMCC Web Design Workshop
MCC Web Design Workshop
 
How to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public ReleaseHow to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public Release
 
Theme Wrangling 101
Theme Wrangling 101Theme Wrangling 101
Theme Wrangling 101
 
Demystifying WordPress Conditional Tags
Demystifying WordPress Conditional TagsDemystifying WordPress Conditional Tags
Demystifying WordPress Conditional Tags
 
Builing a WordPress Theme
Builing a WordPress ThemeBuiling a WordPress Theme
Builing a WordPress Theme
 
WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1WordPress Theme Workshop: Part 1
WordPress Theme Workshop: Part 1
 
Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016
 
Wordpress theme submission requirement for Themeforest
Wordpress theme submission requirement for ThemeforestWordpress theme submission requirement for Themeforest
Wordpress theme submission requirement for Themeforest
 
WordPress Theme Development
 WordPress Theme Development WordPress Theme Development
WordPress Theme Development
 
Theming 101
Theming 101Theming 101
Theming 101
 
WordPress 2.5 Overview - Rich Media Institute
WordPress 2.5 Overview - Rich Media InstituteWordPress 2.5 Overview - Rich Media Institute
WordPress 2.5 Overview - Rich Media Institute
 
Cms & wordpress theme development 2011
Cms & wordpress theme development 2011Cms & wordpress theme development 2011
Cms & wordpress theme development 2011
 
WordPress Theme Development
WordPress Theme DevelopmentWordPress Theme Development
WordPress Theme Development
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond blogging
 
Theme development essentials columbus oh word camp 2012
Theme development essentials   columbus oh word camp 2012Theme development essentials   columbus oh word camp 2012
Theme development essentials columbus oh word camp 2012
 
Streamlining Your Template Structures When Building Themes
Streamlining Your Template Structures When Building ThemesStreamlining Your Template Structures When Building Themes
Streamlining Your Template Structures When Building Themes
 

Similaire à WordPress Theme Workshop: Part 2

Word press bootcamp By Sourcescript Innovations and Mentors Dojo
Word press bootcamp  By Sourcescript Innovations and Mentors DojoWord press bootcamp  By Sourcescript Innovations and Mentors Dojo
Word press bootcamp By Sourcescript Innovations and Mentors Dojo
lightshire
 
Intro to template hierarchy WCTO
Intro to template hierarchy  WCTOIntro to template hierarchy  WCTO
Intro to template hierarchy WCTO
Al Davis
 

Similaire à WordPress Theme Workshop: Part 2 (20)

Intro to WordPress theme development
Intro to WordPress theme developmentIntro to WordPress theme development
Intro to WordPress theme development
 
Anatomy of a Wordpress theme
Anatomy of a Wordpress themeAnatomy of a Wordpress theme
Anatomy of a Wordpress theme
 
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
 
WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
Word press bootcamp By Sourcescript Innovations and Mentors Dojo
Word press bootcamp  By Sourcescript Innovations and Mentors DojoWord press bootcamp  By Sourcescript Innovations and Mentors Dojo
Word press bootcamp By Sourcescript Innovations and Mentors Dojo
 
WordPress Template hierarchy
WordPress Template hierarchyWordPress Template hierarchy
WordPress Template hierarchy
 
Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015
 
WordPress Theming 101
WordPress Theming 101WordPress Theming 101
WordPress Theming 101
 
Customizing WordPress Themes
Customizing WordPress ThemesCustomizing WordPress Themes
Customizing WordPress Themes
 
Intro To WordPress Themes
Intro To WordPress ThemesIntro To WordPress Themes
Intro To WordPress Themes
 
Overview on WordPress theme file structure and working functionality
Overview on WordPress theme file structure and working functionality Overview on WordPress theme file structure and working functionality
Overview on WordPress theme file structure and working functionality
 
Design todevelop
Design todevelopDesign todevelop
Design todevelop
 
Learning Wordpress - the internal guide
Learning Wordpress - the internal guideLearning Wordpress - the internal guide
Learning Wordpress - the internal guide
 
WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3
 
Wordpress theme development
Wordpress theme developmentWordpress theme development
Wordpress theme development
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
 
Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.
 
Intro to template hierarchy WCTO
Intro to template hierarchy  WCTOIntro to template hierarchy  WCTO
Intro to template hierarchy WCTO
 

Plus de David Bisset

WordCamp Tampa 2015
WordCamp Tampa 2015WordCamp Tampa 2015
WordCamp Tampa 2015
David Bisset
 
WPSessions - Thinking Outside The Box With BuddyPress
WPSessions - Thinking Outside The Box With BuddyPressWPSessions - Thinking Outside The Box With BuddyPress
WPSessions - Thinking Outside The Box With BuddyPress
David Bisset
 

Plus de David Bisset (20)

WordPress Theme Workshop: Part 0
WordPress Theme Workshop: Part 0WordPress Theme Workshop: Part 0
WordPress Theme Workshop: Part 0
 
WordPress Theme Workshop: Customizer
WordPress Theme Workshop: CustomizerWordPress Theme Workshop: Customizer
WordPress Theme Workshop: Customizer
 
WordPress Theme Workshop: CSS/JS
WordPress Theme Workshop: CSS/JSWordPress Theme Workshop: CSS/JS
WordPress Theme Workshop: CSS/JS
 
WordPress Theme Workshop: Internationalization
WordPress Theme Workshop: InternationalizationWordPress Theme Workshop: Internationalization
WordPress Theme Workshop: Internationalization
 
WordPress Theme Workshop: Misc
WordPress Theme Workshop: MiscWordPress Theme Workshop: Misc
WordPress Theme Workshop: Misc
 
WordPress Theme Workshop: Widgets
WordPress Theme Workshop: WidgetsWordPress Theme Workshop: Widgets
WordPress Theme Workshop: Widgets
 
WordPress Theme Workshop: Menus
WordPress Theme Workshop: MenusWordPress Theme Workshop: Menus
WordPress Theme Workshop: Menus
 
WordPress Theme Workshop: Sidebars
WordPress Theme Workshop: SidebarsWordPress Theme Workshop: Sidebars
WordPress Theme Workshop: Sidebars
 
WordPress Theme Workshop: Theme Setup
WordPress Theme Workshop: Theme SetupWordPress Theme Workshop: Theme Setup
WordPress Theme Workshop: Theme Setup
 
BuddyPress & Higher Education
BuddyPress & Higher EducationBuddyPress & Higher Education
BuddyPress & Higher Education
 
WordPress Meetup (Davie, FL) - Top 9 April 2016
WordPress Meetup (Davie, FL) - Top 9 April 2016WordPress Meetup (Davie, FL) - Top 9 April 2016
WordPress Meetup (Davie, FL) - Top 9 April 2016
 
WordCamp Tampa 2015
WordCamp Tampa 2015WordCamp Tampa 2015
WordCamp Tampa 2015
 
BuddyPress v4
BuddyPress v4BuddyPress v4
BuddyPress v4
 
WPSessions - Thinking Outside The Box With BuddyPress
WPSessions - Thinking Outside The Box With BuddyPressWPSessions - Thinking Outside The Box With BuddyPress
WPSessions - Thinking Outside The Box With BuddyPress
 
SunShine PHP
SunShine PHPSunShine PHP
SunShine PHP
 
Building Next Generation Applications With BuddyPress
Building Next Generation Applications With BuddyPressBuilding Next Generation Applications With BuddyPress
Building Next Generation Applications With BuddyPress
 
Be a Part of Something Bigger: Get Involved with WordPress
Be a Part of Something Bigger: Get Involved with WordPressBe a Part of Something Bigger: Get Involved with WordPress
Be a Part of Something Bigger: Get Involved with WordPress
 
WordPress Meetup - Top 9 September 2015
WordPress Meetup - Top 9 September 2015WordPress Meetup - Top 9 September 2015
WordPress Meetup - Top 9 September 2015
 
WordPress Miami Meetup: Top 9 (August 2015)
WordPress Miami Meetup: Top 9 (August 2015)WordPress Miami Meetup: Top 9 (August 2015)
WordPress Miami Meetup: Top 9 (August 2015)
 
Getting Started With Grunt for WordPress Development
Getting Started With Grunt for WordPress DevelopmentGetting Started With Grunt for WordPress Development
Getting Started With Grunt for WordPress Development
 

Dernier

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

WordPress Theme Workshop: Part 2

  • 1. WordPress Theme Workshop: Part 2 November 4th, 2017 David Bisset davidbisset.com / @dimensionmedia
  • 2. What Makes A WordPress Theme The REALLY minimum WordPress theme.
  • 3. What Makes A WordPress Theme The REALLY minimum WordPress theme.
  • 4. What Makes A WordPress Theme More Common To See
  • 5. What You REALLY Need While index.php and a style.css file technically are all you need, in reality most minimum themes need the following: • header.php • footer.php • index.php • style.css • functions.php
  • 6. Theme Folder And Structure Twenty Seventeen Theme organizes its file structure like this… Up to you how to organize. WordPress doesn’t require folders. Best to see what other major themes use. Stick with a common structure.
  • 7. Common Files header.php - This file will contain the code for the header section of the theme; index.php - This is the main file for the theme. It will contain the code for the Main Area and will specify where the other files will be included; sidebar.php - This file will contain the information about the sidebar; footer.php - This file will handle your footer; style.css - This file will handle the styling of your new theme;
  • 8. Template Hierarchy header.php - This file will contain the code for the header section of the theme; index.php - This is the main file for the theme. It will contain the code for the Main Area and will specify where the other files will be included; sidebar.php - This file will contain the information about the sidebar; footer.php - This file will handle your footer; style.css - This file will handle the styling of your new theme; https://developer.wordpress.org/files/2014/10/template-hierarchy.png https://developer.wordpress.org/themes/basics/template-hierarchy/
  • 10. Home Page By default,WordPress sets your site’s home page to display your latest blog posts.This page is called the blog posts index.You can also set your blog posts to display on a separate static page.The template file home.php is used to render the blog posts index, whether it is being used as the front page or on separate static page. If home.php does not exist,WordPress will use index.php. • home.php • index.php
  • 11. Front Page Display The front-page.php template file is used to render your site’s front page, whether the front page displays the blog posts index (mentioned before) or a static page. • front-page.php – Used for both “your latest posts” or “a static page” as set in the front page displays section of Settings → Reading. • home.php – If WordPress cannot find front-page.php and “your latest posts” is set in the front page displays section, it will look for home.php. Additionally, WordPress will look for this file when the posts page is set in the front page displays section. • page.php – When “front page” is set in the front page displays section. • index.php
  • 12. Single Post The single post template file is used to render a single post. • single-{post-type}-{slug}.php – (Since 4.4) First,WordPress looks for a template for the specific post. For example, if post type is product and the post slug is dmc-12,WordPress would look for single- product-dmc-12.php. • single-{post-type}.php – If the post type is product,WordPress would look for single-product.php. • single.php – WordPress then falls back to single.php. • index.php
  • 13. Single Page The single post template file is used to render a single page. • custom template file – The page template assigned to the page. get_page_templates(). • page-{slug}.php – If the page slug is recent-news,WordPress will look to use page-recent-news.php. • page-{id}.php – If the page ID is 6,WordPress will look to use page-6.php. • page.php • singular.php • index.php
  • 14. Category Rendering category archive index pages uses the following path in WordPress: • category-{slug}.php – If the category’s slug is news,WordPress will look for category-news.php. • category-{id}.php – If the category’s ID is 6,WordPress will look for category-6.php. • category.php • archive.php • index.php
  • 15. Tags To display a tag archive index page,WordPress uses the following path: • tag-{slug}.php – If the tag’s slug is sometag,WordPress will look for tag-sometag.php. • tag-{id}.php – If the tag’s ID is 6,WordPress will look for tag-6.php. • tag.php • archive.php • index.php
  • 16. Custom Taxonomies Custom taxonomies use a slightly different template file path: • taxonomy-{taxonomy}-{term}.php – If the taxonomy is sometax, and taxonomy’s term is someterm,WordPress will look for taxonomy-sometax-someterm.php. In the case of post formats, the taxonomy is ‘post_format’ and the terms are ‘post-format-{format}. i.e. taxonomy-post_format-post-format-link.php for the link post format. • taxonomy-{taxonomy}.php – If the taxonomy were sometax, WordPress would look for taxonomy-sometax.php. • taxonomy.php • archive.php • index.php
  • 17. Custom Post Types Custom Post Types use the following path to render the appropriate archive index page. • archive-{post_type}.php – If the post type is product,WordPress will look for archive-product.php. • archive.php • index.php
  • 18. Author Pages Starting To See A Pattern? :-) • author-{nicename}.php – If the author’s nice name is matt, WordPress will look for author-matt.php. • author-{id}.php – If the author’s ID were 6,WordPress will look for author-6.php. • author.php • archive.php • index.php
  • 19. 404 Template Seriously,AreYou Starting To See A Pattern? :-) • 404.php • index.php
  • 20. styles.css The style.css is a stylesheet (CSS) file required for every WordPress theme. /* Theme Name: Twenty Seventeen Theme URI: https://wordpress.org/themes/twentyseventeen/ Author: the WordPress team Author URI: https://wordpress.org/ Description: Twenty Seventeen brings your site to life with immersive featured images and subtle animations. With a focus on business sites, it features multiple sections on the front page as well as widgets, navigation and social menus, a logo, and more. Personalize its asymmetrical grid with a custom color scheme and showcase your multimedia content with post formats. Our default theme for 2017 works great in many languages, for any abilities, and on any device. Version: 1.0 */ https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/
  • 21. styles.css (child theme version) The style.css is a stylesheet (CSS) file required for every WordPress theme. /* Theme Name: Twenty Seventeen Child Theme Template: Twenty Seventeen */ https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/
  • 22. functions.php The functions.php file is where you add unique features to your WordPress theme. Not required but nearly EVERY theme as one. Behaves like a WordPress plugin, adding features and functionality to a WordPress site. You can use it to call WordPress functions and to define your own functions. https://developer.wordpress.org/themes/basics/theme-functions/ <?php /** * Enqueue scripts and styles. */ function testme_scripts() { wp_enqueue_style( 'testme-style', get_stylesheet_uri() ); wp_enqueue_script( 'testme-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true ); wp_enqueue_script( 'testme-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'testme_scripts' );