8. Theme Information
/*
Theme Name: Where do I start?
Theme URI: Your theme's URL
Author: Your name or WordPress.org's username
Author URI: Your web address
Description: This is the minimum for creating a custom theme.
Version: 1.0
Tags: one-column, custom-colors, custom-header, blog, education
*/
10. Templates
โข Control display logic
โข Generate the structure of your HTML
โข Can be created for pages, posts, CPTs, etc.
โข Can include partials
https://developer.wordpress.org/themes/basics/template-hierarchy/
https://developer.wordpress.org/themes/template-๏ฌles-section/page-template-๏ฌles/page-templates/
11. functions.php
โข Acts as a plugin
โข Load scripts and styles
โข Enable theme features
โข sidebars, nav menus, post formats, etc
โข De๏ฌne functions used across several templates
โข Customize your themeโs behavior
https://codex.wordpress.org/Functions_File_Explained
13. What is a Starter Theme?
โข A foundation to start
customizing
โข Leverage existing code
โข Incorporates best practices
โข Created to be re-used and
customized
14. When Should I Use a Starter Theme?
โข Your ๏ฌrst theme
โข Functionality, layouts,
patterns exist already
15. Starter Theme Best Practices
โข Donโt update your theme
โข New functionality or
changes my break it
https://themeshaper.com/2013/10/11/dont-update-your-theme/
17. When to Use a Child Theme
โข A theme exists and can be extended
โข Speed up development time
Child Tmp
CSS
Func
Parent Tmp
CSS
Func
18. Bene๏ฌts of a Child Theme
โข Inherits parent functionality
โข Extend styles, functions and templates
โข Can be updated
โข Donโt have to modify parent code
Child Tmp
CSS
Func
Parent Tmp
CSS
Func
19. How to Create a Child Theme
โข Create a new directory in wp-themes
โข Create a style.css ๏ฌle
โข Change the Template: directory
โข Add templates, functions, styles
Child Tmp
CSS
Func
Parent Tmp
CSS
Func
20. How to Create a Child Theme
/*
ย
Theme Name: Where Do I Start Child Theme
ย
Description: Description of your Child Theme
ย
Author: Your name here
ย
Template: folder
ย
*/
22. Things to Know about Child Templates
โข Parent templates inherited
โข Child templates override parent
templates
โข Can be speci๏ฌc to a page
โข page-{slug}.php
Child Tmp
CSS
Func
Parent Tmp
CSS
Func
23. Things to Know about Child Functions
โข Parent functions will run automatically
โข Child functions load before parent
functions
โข Parent functions can be overridden Child Tmp
CSS
Func
Parent Tmp
CSS
Func
25. Pluggable Functions
if ( ! function_exists( โmy_function' ) ):
function my_function() {
// Your code goes here
}
endif;
26. Function Priority
โข Function priority defaults to โ10โ
โข Child functions run after parent
functions via priority
27. Example: Overriding Functions with Function Priority
add_action( 'init', โmy_functionโ , 15 );
function my_function() {
// Your code goes here.
}
28. Removing Functions
โข Completely removes the function
โข remove_action()
โข Called after the initial function
http://code.tutsplus.com/tutorials/a-guide-to-overriding-parent-theme-functions-in-your-child-theme--cms-22623
function()
29. Example: Removing Functions with remove_action()
add_action( 'wp_loaded', 'remove_parent' );
function remove_parent() {
remove_action( 'init', 'parent_function' );
}
30. Can it be Easier?
โข Thereโs a plugin for that!
https://wordpress.org/plugins/one-click-child-theme/
32. What is a Theme Framework?
โข Code library with tools for commonly used tasks
โข Parent theme allows for updates
โข Support di๏ฌerent development approaches
โข Many existing themes already built
33. Theme Framework Bene๏ฌts
โข Maintain features and optimizations across themes
โข Many built by commercial theme developers
โข Commonly used
โข Support and updates
โข Development ongoing