SlideShare a Scribd company logo
C U S T O M
T H E M E I N G
I N W O R D P R E S S
@ J A M I E S C H M I D
W O R D C A M P K A N S A S C I T Y 2 0 1 7
J A M I E S C H M I D
I ’ M A W O R D P R E S S D E V E L O P E R
I N P O R T L A N D , O R
H I ! I ’ M
THEME FUNCTIONS
customize the default WordPress
functionality to fit your site
THEME HIERARCHY
built-in files to display all
content types
ANATOMY OF A WORDPRESS THEME
as simple or complex as you want, but
really just HTML, CSS, JS, and PHP
WHAT IS A WORDPRESS THEME
& how does it work? it’s not
as scary as you might think!
WHAT WE’LL COVER
HOW DOES WORDPRESS WORK?
ALL WORDPRESS THEMES ARE MADE UP
OF JUST A FEW
ESSENTIAL ELEMENTS:
HTML: The basic building block of all websites, HTML uses
elements enclosed in tags (<tag>like this<tag>), to
communicate the meaning and structure of your content.
PHP: A scripting language that runs server-side, PHP is
used to generate the elements of your web page.
CSS: A way to control the look and formatting of your entire
website using one file (or more) that styles the HTML on
your site: style.css.
(OFTEN) JAVASCRIPT: A scripting language that adds
additional functionality to your site, both client and
serverside.
IMAGES: JPEG, PNG, SVG files that are uploaded to your
media library, or in a folder of your theme
The Basic Elements
of a WordPress Theme
The bare minimum.
A WordPress theme is a group of templates and a stylesheet that displays content
in your database uploaded via the WordPress admin.
AT A MINIMUM, YOU NEED:
index.php
style.css
Example files and folders
of a modestly-sized theme.
THAT’S LITERALLY IT.
Theme file:
STYLE.CSS
• A stylesheet (CSS) file, required to
recognize the set of theme
template
files as a valid theme.
• Controls the presentation (visual
design and layout) of the websitepages.
•
Must be named style.css.
• Must be located in the root
directory of your theme, not asubdirectory.
• Must include information about the
theme in the top comments
The Required Elements
of style.css (in theme repository)
WHAT STYLE.CSS GETS US
Theme file:
INDEX.PHP
• The default page rendering template file
• If no other template files are available,
WordPress uses this file to render everything
on your site
• Contains the WordPress loop.
• Like any other page rendering files, you
can include other files inside of here for
organization sake
• must call wp_head() function
• must call wp_footer() function
• must contain the loop
TEMPLATE TAGS
• A PHP code tag
• A WordPress function
• Optional parameters
Typical Template Tags:A piece of code that tells WordPress
to get something from the database. It
is broken up into three components:
Reference: Template Tags in the Codex
The WordPress Loop
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php else : ?>
<h2>Sorry, no posts here!</h2>
<?php endif; ?>
THEME FUNCTIONS
HOW TO FIND THEM
• referencing Developer/Codex
• finding functions in Core
COMMON FUNCTIONS
• bloginfo()
• the_content()
• the_title()
• the_permalink()
• the_post_thumbnail()
• is_page()
• is_frontpage()
• is_active_sidebar()
• body_class()
• + many more!
TYPES OF FUNCTIONS
• content display (template tags)
• conditional tags
• hooks
Theme file:
FUNCTIONS.PHP
ENQUEUEING CSS & JS
• don’t link directly in the header
• use wp_enqueue_scripts() in
functions.php
REGISTER NAV MENUS
• nav menus must be registered in
your theme to show up in the Admin
• use register_nav_menus() in
functions.php
THUMBNAIL SUPPORT
• enables the “featured image” section
in posts and pages
• use
add_theme_support( 'post-
thumbnails' )
REGISTER WIDGET AREAS
• you need to “widgetize” your theme
• use register_sidebar() in
functions.php
WHEN TO USE FUNCTIONS.PHP
VS
WHEN TO USE/CREATE A PLUGIN
• lives in theme folder
• changes default behavior of
WordPress
• behaves like WP plugin
• use built-in WP functions or create
your own
• register menu, sidebar, widgets
• enqueue CSS and JS
• functionality only works when your
theme is active
FUNCTIONS.PHP
• lives in plugins folder
• changes default behavior of WordPress
• lives completely independently of
your theme
• use built-in WP functions or create
your own
• endless possibilities to extend WordPress
• use a plugin to define custom content -
keep content separate from presentation!
PLUGIN
THEME FILES
can get very complex.
the opposite of bare minimum:
(looking at Divi’s theme files)
The Divi theme includes a drag-and-drop
pagebuilder, customizable everything,
shortcodes, widgets, front-end editing, and
more!
WordPress has a great built-in template file system that allows you to
organize and reuse your files according to individual layouts and
content types. And it’s really useful!
The Template Hierarchy
Like Cascading Style Sheets, it first looks for the MOST SPECIFIC
file name; if it doesn’t exist, it gets less and less specific until it ends
up at …. index.php!
https://wphierarchy.com/
A visual resource to help you decide what to name your template file
Our sample project:
Seafuzz
A small website for a Portland band with the basics: homepage, photos, tour dates, YouTube and
Bandcamp embeds, Mailchimp signup form. We will be starting with a functional static site, and
translating it to a custom WordPress theme.
THE THEME FILES & FOLDERSWE’LL BE USING:
index.php
style.css
functions.php
header.php
page.php
sidebar.php
footer.php
img/
Note: there are MANY other ways to build
this! This is just one basic solution.
THINGS TO DO BEFORE YOUR THEME
• Create your pages. Use loremipsum if you need to.
• Set your homepage and blogpage (if applicable).
•
Set your permalinks.
•
Configure your plugins.
You’re going to need content to style. WordPress keeps all
content inside the database. To wp-admin we go!
• Wait on menus - you define thesein your theme
• Wait on widgets - you define these
in your theme
Let’s build a WordPress theme!
DEMO TIME!
As you do more and more themes…
you will find yourself reusing certain code…
even certain pages…
maybe even a whole default theme you build off of each time.
This is called a starter theme.
And some people have built some great ones for you to use!
I know what you’re thinking.
And you’re right.
STARTER THEMES
• A group of theme files, HTML, CSS and theme functions madeto act as a starting point for custom theme development
• NOT a framework! NOT a commercial theme! NOT meant fora child theme!
• Takes out the “busy work” and lets you get right down to
building your theme
EXAMPLES:
• _s (Underscores)
• FoundationPress • Understrap (bootstrap & _s)
• Sage (advanced!)
RESOURCES
• lynda.com: Custom Themeing
• WP Beginner
• the Codex: Theme Development
• the Codex: Functions
• the Developers Guidebook
• the Template Hierarchy
• _s (underscores)
• these slides
T H A N K Y O U !
Q U E S T I O N S ?
@ J A M I E S C H M I D
W O R D C A M P K A N S A S C I T Y 2 0 1 7

More Related Content

PPTX
WordPress Theme Development: Part 2
PDF
WordPress Theme Structure
PPTX
Custom WordPress theme development
PPTX
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
PDF
Intro to WordPress theme development
PDF
Theme Wrangling 101
PDF
WordPress Theme Workshop: Part 2
PDF
How to Prepare a WordPress Theme for Public Release
WordPress Theme Development: Part 2
WordPress Theme Structure
Custom WordPress theme development
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
Intro to WordPress theme development
Theme Wrangling 101
WordPress Theme Workshop: Part 2
How to Prepare a WordPress Theme for Public Release

What's hot (20)

PPTX
Theme development essentials columbus oh word camp 2012
PDF
Introduction to WordPress Theme Development
PDF
Word press templates
PDF
WordPress Theme Workshop: Part 4
PPT
WordPress Child Themes
KEY
WordPress Developers Israel Meetup #1
PPT
Custom Menu Support for WordPress Themes
PDF
WordPress Theme Development
ODP
Meetup child-themes
PDF
Minimalist Theming: How to Build a Lean, Mean Drupal 8 Theme
PDF
WordPress Theme Development Basics
PPTX
Word press bootcamp By Sourcescript Innovations and Mentors Dojo
PDF
There's No Crying In Wordpress! (an intro to WP)
KEY
Intro To WordPress Themes
PPTX
WordPress Theme Development
PPTX
The Way to Theme Enlightenment
PPTX
Web 101 intro to html
PPTX
Creating Customizable Widgets for Unpredictable Needs
PPTX
Wordpress theme submission requirement for Themeforest
Theme development essentials columbus oh word camp 2012
Introduction to WordPress Theme Development
Word press templates
WordPress Theme Workshop: Part 4
WordPress Child Themes
WordPress Developers Israel Meetup #1
Custom Menu Support for WordPress Themes
WordPress Theme Development
Meetup child-themes
Minimalist Theming: How to Build a Lean, Mean Drupal 8 Theme
WordPress Theme Development Basics
Word press bootcamp By Sourcescript Innovations and Mentors Dojo
There's No Crying In Wordpress! (an intro to WP)
Intro To WordPress Themes
WordPress Theme Development
The Way to Theme Enlightenment
Web 101 intro to html
Creating Customizable Widgets for Unpredictable Needs
Wordpress theme submission requirement for Themeforest
Ad

Similar to Introduction to Custom WordPress Themeing (20)

PPTX
Wordpress theme development
PPT
WordPress 2.5 Overview - Rich Media Institute
PPT
W pthemes
PDF
Newbies guide to customizing word press themes 25
PDF
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
PPTX
MCC Web Design Workshop
PPTX
Customizing WordPress Themes
PPTX
WordPress Themes and Plugins
PDF
Firstborn child theme word camp presentation - atlanta 2013
PPTX
Building a WordPress theme
PPTX
Responsive themeworkshop wcneo2016
PDF
WordPress Theming 101
PPT
Wordpress template hierarchy
PDF
Child Themes and CSS in WordPress
PPTX
The Way to Theme Enlightenment 2017
PDF
Intro to WordPress Child Themes (NERDS Sept 2014)
PPTX
HTML/CSS for WordPress
PPTX
Your First Wordpress Theme
PPTX
Keeping Your Themes and Plugins Organized.
PDF
Builing a WordPress Theme
Wordpress theme development
WordPress 2.5 Overview - Rich Media Institute
W pthemes
Newbies guide to customizing word press themes 25
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
MCC Web Design Workshop
Customizing WordPress Themes
WordPress Themes and Plugins
Firstborn child theme word camp presentation - atlanta 2013
Building a WordPress theme
Responsive themeworkshop wcneo2016
WordPress Theming 101
Wordpress template hierarchy
Child Themes and CSS in WordPress
The Way to Theme Enlightenment 2017
Intro to WordPress Child Themes (NERDS Sept 2014)
HTML/CSS for WordPress
Your First Wordpress Theme
Keeping Your Themes and Plugins Organized.
Builing a WordPress Theme
Ad

More from Jamie Schmid (20)

PDF
Content Architectures in WordPress 5
PDF
Content Strategy in a Gutenberg World Lightning Talk at WordCamp Phoenix 2019
PDF
Dont Break Live lightning talk
PDF
Introduction to WooCommerce
PDF
Securing your WooCommerce Site
PDF
WooCommerce Security - WordCamp OC 2018
PDF
Remote Project Management WordCamp OC 2018
PDF
YAY I'm Working Remotely! Now What?
PDF
Making Security Make Sense to Users and Clients
PPTX
Making Security Make Sense to Users and Clients
PPTX
Introduction to Content Strategy: SANDCamp 2018
PDF
Content Doesn't Grow on Trees - An Introduction to Content Strategy
PDF
Introduction to Content Strategy - WordCamp Montreal 2016
PPTX
Content Architecture in WordPress
PPTX
Content Doesn't Grow on Trees - Intruduction to Content Strategy
PPTX
WCCBUS 2015 - Content Architecture in WordPress
PPTX
Structuring Content in WordPress using Advanced Custom Fields
PPTX
Structuring Content in WordPress using Advanced Custom Fields
PPTX
WordPress Beginner: Choosing & Customizing Your Theme
PDF
Structuring Content in WordPress: Against All the Odds
Content Architectures in WordPress 5
Content Strategy in a Gutenberg World Lightning Talk at WordCamp Phoenix 2019
Dont Break Live lightning talk
Introduction to WooCommerce
Securing your WooCommerce Site
WooCommerce Security - WordCamp OC 2018
Remote Project Management WordCamp OC 2018
YAY I'm Working Remotely! Now What?
Making Security Make Sense to Users and Clients
Making Security Make Sense to Users and Clients
Introduction to Content Strategy: SANDCamp 2018
Content Doesn't Grow on Trees - An Introduction to Content Strategy
Introduction to Content Strategy - WordCamp Montreal 2016
Content Architecture in WordPress
Content Doesn't Grow on Trees - Intruduction to Content Strategy
WCCBUS 2015 - Content Architecture in WordPress
Structuring Content in WordPress using Advanced Custom Fields
Structuring Content in WordPress using Advanced Custom Fields
WordPress Beginner: Choosing & Customizing Your Theme
Structuring Content in WordPress: Against All the Odds

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Big Data Technologies - Introduction.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
cuic standard and advanced reporting.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Encapsulation theory and applications.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Weekly Chronicles - August'25 Week I
Reach Out and Touch Someone: Haptics and Empathic Computing
Dropbox Q2 2025 Financial Results & Investor Presentation
Understanding_Digital_Forensics_Presentation.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Big Data Technologies - Introduction.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
cuic standard and advanced reporting.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation_ Review paper, used for researhc scholars
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Encapsulation theory and applications.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Review of recent advances in non-invasive hemoglobin estimation

Introduction to Custom WordPress Themeing

  • 1. C U S T O M T H E M E I N G I N W O R D P R E S S @ J A M I E S C H M I D W O R D C A M P K A N S A S C I T Y 2 0 1 7
  • 2. J A M I E S C H M I D I ’ M A W O R D P R E S S D E V E L O P E R I N P O R T L A N D , O R H I ! I ’ M
  • 3. THEME FUNCTIONS customize the default WordPress functionality to fit your site THEME HIERARCHY built-in files to display all content types ANATOMY OF A WORDPRESS THEME as simple or complex as you want, but really just HTML, CSS, JS, and PHP WHAT IS A WORDPRESS THEME & how does it work? it’s not as scary as you might think! WHAT WE’LL COVER
  • 5. ALL WORDPRESS THEMES ARE MADE UP OF JUST A FEW ESSENTIAL ELEMENTS: HTML: The basic building block of all websites, HTML uses elements enclosed in tags (<tag>like this<tag>), to communicate the meaning and structure of your content. PHP: A scripting language that runs server-side, PHP is used to generate the elements of your web page. CSS: A way to control the look and formatting of your entire website using one file (or more) that styles the HTML on your site: style.css. (OFTEN) JAVASCRIPT: A scripting language that adds additional functionality to your site, both client and serverside. IMAGES: JPEG, PNG, SVG files that are uploaded to your media library, or in a folder of your theme The Basic Elements of a WordPress Theme
  • 6. The bare minimum. A WordPress theme is a group of templates and a stylesheet that displays content in your database uploaded via the WordPress admin. AT A MINIMUM, YOU NEED: index.php style.css Example files and folders of a modestly-sized theme. THAT’S LITERALLY IT.
  • 7. Theme file: STYLE.CSS • A stylesheet (CSS) file, required to recognize the set of theme template files as a valid theme. • Controls the presentation (visual design and layout) of the websitepages. • Must be named style.css. • Must be located in the root directory of your theme, not asubdirectory. • Must include information about the theme in the top comments The Required Elements of style.css (in theme repository)
  • 9. Theme file: INDEX.PHP • The default page rendering template file • If no other template files are available, WordPress uses this file to render everything on your site • Contains the WordPress loop. • Like any other page rendering files, you can include other files inside of here for organization sake • must call wp_head() function • must call wp_footer() function • must contain the loop
  • 10. TEMPLATE TAGS • A PHP code tag • A WordPress function • Optional parameters Typical Template Tags:A piece of code that tells WordPress to get something from the database. It is broken up into three components: Reference: Template Tags in the Codex
  • 11. The WordPress Loop <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <?php the_title(); ?> <?php the_content(); ?> <?php endwhile; ?> <?php else : ?> <h2>Sorry, no posts here!</h2> <?php endif; ?>
  • 12. THEME FUNCTIONS HOW TO FIND THEM • referencing Developer/Codex • finding functions in Core COMMON FUNCTIONS • bloginfo() • the_content() • the_title() • the_permalink() • the_post_thumbnail() • is_page() • is_frontpage() • is_active_sidebar() • body_class() • + many more! TYPES OF FUNCTIONS • content display (template tags) • conditional tags • hooks
  • 13. Theme file: FUNCTIONS.PHP ENQUEUEING CSS & JS • don’t link directly in the header • use wp_enqueue_scripts() in functions.php REGISTER NAV MENUS • nav menus must be registered in your theme to show up in the Admin • use register_nav_menus() in functions.php THUMBNAIL SUPPORT • enables the “featured image” section in posts and pages • use add_theme_support( 'post- thumbnails' ) REGISTER WIDGET AREAS • you need to “widgetize” your theme • use register_sidebar() in functions.php
  • 14. WHEN TO USE FUNCTIONS.PHP VS WHEN TO USE/CREATE A PLUGIN • lives in theme folder • changes default behavior of WordPress • behaves like WP plugin • use built-in WP functions or create your own • register menu, sidebar, widgets • enqueue CSS and JS • functionality only works when your theme is active FUNCTIONS.PHP • lives in plugins folder • changes default behavior of WordPress • lives completely independently of your theme • use built-in WP functions or create your own • endless possibilities to extend WordPress • use a plugin to define custom content - keep content separate from presentation! PLUGIN
  • 15. THEME FILES can get very complex. the opposite of bare minimum: (looking at Divi’s theme files) The Divi theme includes a drag-and-drop pagebuilder, customizable everything, shortcodes, widgets, front-end editing, and more!
  • 16. WordPress has a great built-in template file system that allows you to organize and reuse your files according to individual layouts and content types. And it’s really useful! The Template Hierarchy Like Cascading Style Sheets, it first looks for the MOST SPECIFIC file name; if it doesn’t exist, it gets less and less specific until it ends up at …. index.php! https://wphierarchy.com/ A visual resource to help you decide what to name your template file
  • 17. Our sample project: Seafuzz A small website for a Portland band with the basics: homepage, photos, tour dates, YouTube and Bandcamp embeds, Mailchimp signup form. We will be starting with a functional static site, and translating it to a custom WordPress theme. THE THEME FILES & FOLDERSWE’LL BE USING: index.php style.css functions.php header.php page.php sidebar.php footer.php img/ Note: there are MANY other ways to build this! This is just one basic solution.
  • 18. THINGS TO DO BEFORE YOUR THEME • Create your pages. Use loremipsum if you need to. • Set your homepage and blogpage (if applicable). • Set your permalinks. • Configure your plugins. You’re going to need content to style. WordPress keeps all content inside the database. To wp-admin we go! • Wait on menus - you define thesein your theme • Wait on widgets - you define these in your theme
  • 19. Let’s build a WordPress theme! DEMO TIME!
  • 20. As you do more and more themes… you will find yourself reusing certain code… even certain pages… maybe even a whole default theme you build off of each time. This is called a starter theme. And some people have built some great ones for you to use! I know what you’re thinking. And you’re right.
  • 21. STARTER THEMES • A group of theme files, HTML, CSS and theme functions madeto act as a starting point for custom theme development • NOT a framework! NOT a commercial theme! NOT meant fora child theme! • Takes out the “busy work” and lets you get right down to building your theme EXAMPLES: • _s (Underscores) • FoundationPress • Understrap (bootstrap & _s) • Sage (advanced!)
  • 22. RESOURCES • lynda.com: Custom Themeing • WP Beginner • the Codex: Theme Development • the Codex: Functions • the Developers Guidebook • the Template Hierarchy • _s (underscores) • these slides
  • 23. T H A N K Y O U ! Q U E S T I O N S ? @ J A M I E S C H M I D W O R D C A M P K A N S A S C I T Y 2 0 1 7

Editor's Notes

  • #22: WordPress starter theme that includes most of the default functions you will need free to download SASS version bare bones styling organized theme files reusable HTML sections