SlideShare a Scribd company logo
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
FRAMEWORKS, PARENTS & CHILDREN
• Parent Theme
• A base theme that sets up functionality
• Can be extended
• Must be written to allow overrides
• Child Theme
• Extends a parent theme
• Can carry over or override elements from parent
• Cannot be extended without plugins
• Framework
• Not a full theme; more of a plugin for a theme
• Allows creation of parent and child themes with shared functionality
http://justintadlock.com/archives/2010/08/16/frameworks-parent-child-and-grandchild-themes
EXAMPLES
Hybrid Core is a framework. - http://themehybrid.com/hybrid-core
• No theme structure
• Full package goes inside parent theme
Genesis “Framework” is a parent theme -
http://www.studiopress.com/features
• Has a theme structure
• Can be used on its own
• Does not go inside of another theme
TwentyTwelve is a parent theme -
http://wordpress.org/extend/themes/twentytwelve
• Although it has less of a framework built in, same concept as Genesis
“Education” is a child theme - http://my.studiopress.com/themes/education/
• Cannot be used without Genesis (parent theme) installed
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
REQUIRED FILES
CSS Stylesheet (style.css)*
• Implements the CSS for the theme
• Not included by default
• enqueue it in functions.php or
• use <link href=“<?php bloginfo( „stylesheet_uri‟ ) ?>”/> in <head>
• Provides base information about the theme
• Theme name, URI, version, license, etc.
(http://codex.wordpress.org/Theme_Development#Theme_Stylesheet)
Index (index.php)
• Implements the structure of the theme
• Can be split out into multiple files
• Acts as fallback for all pages**
* - style.css is the only file required in a child theme; all others fallback to parent theme
** - the Template Hierarchy governs which files are used for each page; index is the final fallback
TYPICAL THEME FILES
Theme Functions (functions.php)
• Central location for function, variable, constant defintions used in theme
• Included automatically by theme engine before after_setup_theme action
Default Sidebar (sidebar.php)
• Outputs default sidebar (get_sidebar())
Default WordPress Loop (loop.php)
• Not included automatically by theme
• Used to separate “the loop”*** from other structure
Comments Template (comments.php)
• List of comments and comment form; use comments_template() to include
Search (search.php)
• Search results template; automatically used on search results page
MOAR THEME FILES
Automatic Template Files (page.php, 404.php, single.php)
• Used automatically based on type of page being shown;
• Overrides index.php (see the Template Hierarchy)
Miscellaneous Files (sidebar-[slug].php, etc.)
• Include with the get_template_part( „sidebar‟, „[slug]‟ ) function
• Sidebar, header and footer files can be included with:
• get_sidebar( ‘[slug]’ )
• get_header( ‘[slug]’ )
• get_footer( ‘[slug]’ )
Header and Footer (header.php, footer.php)
• Not included automatically
• Call with get_header() & get_footer()
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
THE WORDPRESS TEMPLATE HIERARCHY
WordPress automatically searches for appropriate theme template file
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
WHAT IS “THE LOOP”?
The Loop outputs the main content area
• Loops through all matching content objects
if ( have_posts() ) : while ( have_posts() ) : the_post();
// Output all of your content
endwhile; endif;
have_posts() and the_post()
• Global methods of main query object ($wp_query)
• have_posts() generates array of “post” objects
• the_post() sets global variables related to current post object
OTHER “LOOP” FUNCTIONS
Inside the loop, various functions are available
• the_title() – echoes the title of the current post
• the_content() – echoes the body of the current post
• the_post_thumbnail() – echoes the “featured image” for current post
MOAR LOOP TIPS
If you need to use the same query loop more than once:
• Use rewind_posts() to reset the loop to be used again
You can start your own loop with a custom query:
$myquery = new WP_Query( ‘[query parameters go here]’ );
if ( $myquery->have_posts() ) : while ( $myquery-
>have_posts() ) : $myquery->the_post();
// Your custom loop stuff here
endwhile; endif;
• Don’t alter the global $wp_query or use query_posts() unless you know
what you’re doing
• Use get_posts() or create your own loop, instead
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
STEP 1: DESIGN
• Identify goals
• Wireframe and design
• Layout priorities
• Final template design
• Initial HTML layout
STEP 2: DIVIDE AND CONQUER
• Identify layout elements
• Identify content elements
• Identify visual decoration
• Determine common elements
• Identify alternative layouts
STEP 3: DEVELOP
• Begin developing basic layout
• Separate layout elements from
content elements
• Replace content elements with
placeholders
• Create layout structure and style
• Develop content containers
(body, widgets, footer, header,
etc.)
• Develop custom functionality
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
LET’S DO THIS THING
Examine Theme Design – http://2013.highedweb.org/
Identify Theme Elements
Create required files
style.css - http://j.mp/153SWWv
index.php – wp_head() & wp_footer() - http://j.mp/153Tagt
functions.php (not required, but recommended)
QUESTIONS? COMMENTS?
Twitter: @cgrymala
Website(s): http://umw.edu/ (Multi-Network Setup)
http://ten-321.com/
http://svn.ten-321.com/ (SVN Repo)
http://wphighed.org/ (WP resources for Higher Ed)
Email: cgrymala@umw.edu
curtiss@ten-321.com
SpeakerRate: http://spkr8.com/s/10608
http://about.me/cgrymala

More Related Content

PPTX
WordPress Themes 101 - PSUWeb13 Workshop
PPTX
WordPress Themes 101 - HighEdWeb New England 2013
PPTX
WordPress Themes 101 - dotEduGuru Summit 2013
PPSX
WordPress Theme Design and Development Workshop - Day 2
KEY
What's New in WordPress 3.0 (for developers)
PPTX
Design todevelop
PPTX
Responsive themeworkshop wcneo2016
PPTX
Starting WordPress Theme Review
WordPress Themes 101 - PSUWeb13 Workshop
WordPress Themes 101 - HighEdWeb New England 2013
WordPress Themes 101 - dotEduGuru Summit 2013
WordPress Theme Design and Development Workshop - Day 2
What's New in WordPress 3.0 (for developers)
Design todevelop
Responsive themeworkshop wcneo2016
Starting WordPress Theme Review

What's hot (20)

PPTX
Drupal 8 theming
PDF
Minimalist Theming: How to Build a Lean, Mean Drupal 8 Theme
PDF
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
PPTX
Creating Web Templates for SharePoint 2010
PDF
Creating a Reusable Drupal Website for Higher Education - at USG Tech Day
PDF
Creating a Reusable Drupal Website for Higher Education - Webinar
PDF
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
PPT
WordPress Child Themes
PDF
A Custom Drupal Theme in 40 Minutes
PDF
WordPress Theme Workshop: Part 2
PDF
Turbo charged WordPress theme development - WordCamp Edinburgh 2012
PPTX
WordPress Template hierarchy
PDF
WordPress Template Hierarchy
PPTX
How to get your theme in WordPress
PPTX
10 Steps Not To Forget After Installing Drupal
PPTX
YAG - Yet Another Gallery / T3CON11
PDF
YAG - Yet Another Gallery
PDF
flickr's architecture & php
PDF
EECI 2010 - The Power of ExpressionEngine's Dynamic Templates
PPTX
WordPress Themes and Plugins
Drupal 8 theming
Minimalist Theming: How to Build a Lean, Mean Drupal 8 Theme
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Web Templates for SharePoint 2010
Creating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - Webinar
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
WordPress Child Themes
A Custom Drupal Theme in 40 Minutes
WordPress Theme Workshop: Part 2
Turbo charged WordPress theme development - WordCamp Edinburgh 2012
WordPress Template hierarchy
WordPress Template Hierarchy
How to get your theme in WordPress
10 Steps Not To Forget After Installing Drupal
YAG - Yet Another Gallery / T3CON11
YAG - Yet Another Gallery
flickr's architecture & php
EECI 2010 - The Power of ExpressionEngine's Dynamic Templates
WordPress Themes and Plugins
Ad

Similar to Writing a WordPress Theme - HighEdWeb 2013 #WRK2 (20)

PPTX
Wordpress theme development
PDF
Theming in WordPress - Where do I Start?
PPTX
The Way to Theme Enlightenment 2017
PPTX
The Way to Theme Enlightenment
PDF
Theming moodle technical
PDF
Intro to WordPress theme development
PPTX
Basic word press development
PDF
Anatomy of a Wordpress theme
PDF
Intro to WordPress Child Themes (NERDS Sept 2014)
PDF
WCLV - Introduction to child themes
PPTX
The WordPress University
PPTX
full-site-editing-theme-presentation.pptx
PPTX
Wordpress overview
KEY
WordPress Child Themes
PPTX
Keeping Your Themes and Plugins Organized.
PDF
Builing a WordPress Theme
PDF
Drupal theming - a practical approach (European Drupal Days 2015)
PDF
Arizona WP - Building a WordPress Theme
PPTX
Introduction to Custom WordPress Themeing
PDF
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Wordpress theme development
Theming in WordPress - Where do I Start?
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment
Theming moodle technical
Intro to WordPress theme development
Basic word press development
Anatomy of a Wordpress theme
Intro to WordPress Child Themes (NERDS Sept 2014)
WCLV - Introduction to child themes
The WordPress University
full-site-editing-theme-presentation.pptx
Wordpress overview
WordPress Child Themes
Keeping Your Themes and Plugins Organized.
Builing a WordPress Theme
Drupal theming - a practical approach (European Drupal Days 2015)
Arizona WP - Building a WordPress Theme
Introduction to Custom WordPress Themeing
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Ad

More from Curtiss Grymala (8)

PPTX
WordPress as a CMS
PPTX
WordPress in HigherEd
PPTX
Umw WordPress Primer
PPTX
Writing a WordPress Plugin: #heweb12
PPTX
10 Minute WordPress Shortcode
PPTX
Writing a WordPress Plugin
PPTX
WordPress Coding Standards
PPTX
WordPress Multi-Network
WordPress as a CMS
WordPress in HigherEd
Umw WordPress Primer
Writing a WordPress Plugin: #heweb12
10 Minute WordPress Shortcode
Writing a WordPress Plugin
WordPress Coding Standards
WordPress Multi-Network

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Empathic Computing: Creating Shared Understanding
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
Electronic commerce courselecture one. Pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
NewMind AI Monthly Chronicles - July 2025
Chapter 3 Spatial Domain Image Processing.pdf
A Presentation on Artificial Intelligence
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Spectral efficient network and resource selection model in 5G networks
MYSQL Presentation for SQL database connectivity
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Empathic Computing: Creating Shared Understanding
20250228 LYD VKU AI Blended-Learning.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Machine learning based COVID-19 study performance prediction
Advanced methodologies resolving dimensionality complications for autism neur...
NewMind AI Weekly Chronicles - August'25 Week I
Reach Out and Touch Someone: Haptics and Empathic Computing
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation_ Review paper, used for researhc scholars
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Understanding_Digital_Forensics_Presentation.pptx

Writing a WordPress Theme - HighEdWeb 2013 #WRK2

  • 4. FRAMEWORKS, PARENTS & CHILDREN • Parent Theme • A base theme that sets up functionality • Can be extended • Must be written to allow overrides • Child Theme • Extends a parent theme • Can carry over or override elements from parent • Cannot be extended without plugins • Framework • Not a full theme; more of a plugin for a theme • Allows creation of parent and child themes with shared functionality http://justintadlock.com/archives/2010/08/16/frameworks-parent-child-and-grandchild-themes
  • 5. EXAMPLES Hybrid Core is a framework. - http://themehybrid.com/hybrid-core • No theme structure • Full package goes inside parent theme Genesis “Framework” is a parent theme - http://www.studiopress.com/features • Has a theme structure • Can be used on its own • Does not go inside of another theme TwentyTwelve is a parent theme - http://wordpress.org/extend/themes/twentytwelve • Although it has less of a framework built in, same concept as Genesis “Education” is a child theme - http://my.studiopress.com/themes/education/ • Cannot be used without Genesis (parent theme) installed
  • 7. REQUIRED FILES CSS Stylesheet (style.css)* • Implements the CSS for the theme • Not included by default • enqueue it in functions.php or • use <link href=“<?php bloginfo( „stylesheet_uri‟ ) ?>”/> in <head> • Provides base information about the theme • Theme name, URI, version, license, etc. (http://codex.wordpress.org/Theme_Development#Theme_Stylesheet) Index (index.php) • Implements the structure of the theme • Can be split out into multiple files • Acts as fallback for all pages** * - style.css is the only file required in a child theme; all others fallback to parent theme ** - the Template Hierarchy governs which files are used for each page; index is the final fallback
  • 8. TYPICAL THEME FILES Theme Functions (functions.php) • Central location for function, variable, constant defintions used in theme • Included automatically by theme engine before after_setup_theme action Default Sidebar (sidebar.php) • Outputs default sidebar (get_sidebar()) Default WordPress Loop (loop.php) • Not included automatically by theme • Used to separate “the loop”*** from other structure Comments Template (comments.php) • List of comments and comment form; use comments_template() to include Search (search.php) • Search results template; automatically used on search results page
  • 9. MOAR THEME FILES Automatic Template Files (page.php, 404.php, single.php) • Used automatically based on type of page being shown; • Overrides index.php (see the Template Hierarchy) Miscellaneous Files (sidebar-[slug].php, etc.) • Include with the get_template_part( „sidebar‟, „[slug]‟ ) function • Sidebar, header and footer files can be included with: • get_sidebar( ‘[slug]’ ) • get_header( ‘[slug]’ ) • get_footer( ‘[slug]’ ) Header and Footer (header.php, footer.php) • Not included automatically • Call with get_header() & get_footer()
  • 11. THE WORDPRESS TEMPLATE HIERARCHY WordPress automatically searches for appropriate theme template file
  • 13. WHAT IS “THE LOOP”? The Loop outputs the main content area • Loops through all matching content objects if ( have_posts() ) : while ( have_posts() ) : the_post(); // Output all of your content endwhile; endif; have_posts() and the_post() • Global methods of main query object ($wp_query) • have_posts() generates array of “post” objects • the_post() sets global variables related to current post object
  • 14. OTHER “LOOP” FUNCTIONS Inside the loop, various functions are available • the_title() – echoes the title of the current post • the_content() – echoes the body of the current post • the_post_thumbnail() – echoes the “featured image” for current post
  • 15. MOAR LOOP TIPS If you need to use the same query loop more than once: • Use rewind_posts() to reset the loop to be used again You can start your own loop with a custom query: $myquery = new WP_Query( ‘[query parameters go here]’ ); if ( $myquery->have_posts() ) : while ( $myquery- >have_posts() ) : $myquery->the_post(); // Your custom loop stuff here endwhile; endif; • Don’t alter the global $wp_query or use query_posts() unless you know what you’re doing • Use get_posts() or create your own loop, instead
  • 18. STEP 1: DESIGN • Identify goals • Wireframe and design • Layout priorities • Final template design • Initial HTML layout
  • 19. STEP 2: DIVIDE AND CONQUER • Identify layout elements • Identify content elements • Identify visual decoration • Determine common elements • Identify alternative layouts
  • 20. STEP 3: DEVELOP • Begin developing basic layout • Separate layout elements from content elements • Replace content elements with placeholders • Create layout structure and style • Develop content containers (body, widgets, footer, header, etc.) • Develop custom functionality
  • 22. LET’S DO THIS THING Examine Theme Design – http://2013.highedweb.org/ Identify Theme Elements Create required files style.css - http://j.mp/153SWWv index.php – wp_head() & wp_footer() - http://j.mp/153Tagt functions.php (not required, but recommended)
  • 23. QUESTIONS? COMMENTS? Twitter: @cgrymala Website(s): http://umw.edu/ (Multi-Network Setup) http://ten-321.com/ http://svn.ten-321.com/ (SVN Repo) http://wphighed.org/ (WP resources for Higher Ed) Email: cgrymala@umw.edu curtiss@ten-321.com SpeakerRate: http://spkr8.com/s/10608 http://about.me/cgrymala