SlideShare une entreprise Scribd logo
1  sur  38
Télécharger pour lire hors ligne
Child Themes
Won’t someone think of the
children?
By Damien Carbery
Photo: https://flic.kr/p/ccHYYL by Justkids
Intro - What's the
problem?
Editing core files is bad.
Editing themes is bad.
Child themes are easy.
Why do you need a child theme?
Perfect … Except
for just one thing
A child theme can help.
Photo: https://flic.kr/p/4bnRok by m.a.r.c.
Let’s create a child theme
Just one file
/*
Name: Child Theme
Template: twentyfifteen
*/
That’s it. Done. Now go Activate it.
What can you do now?
● Change the styles
● Change the layout of posts, pages, archives
or individual ones
● Add new features e.g. add support for
WooCommerce
Changing styles
This is the simplest, least
technical thing that you can
do.
Changing styles Change the page font from
“Noto Serif” to Arial:
body { font-family:
Arial, serif; }
Changing styles
Changing styles
Change the header colours
from #333 to red:
h1, h2, h3, h4, h5,
h6 {
color: #f00;
}
Changing styles
Changing styles
Change ul marker from disc
to a circle:
ul {
list-style: circle;
}
Changing styles
Beyond style changes
Beyond style
changes You can copy a file from the
parent theme and modify it.
Twenty Fifteen displays the
full post content on archive
pages. Let’s change it to
show excerpts.
Excerpts in
Archives
Copy the template file and make your
change.
archive.php displays the
archive.
It uses content.php.
That calls the_content()
so change it to
the_excerpt()
Excerpts in
Archives ....
You have to edit carefully and check
your work.
Now test the change - oops, single pages,
single posts are showing excerpts. The fix:
The code will be:
if (is_archive() ) {
the_excerpt();
}
else {
the_content(
sprintf(
'Continue reading %s',
the_title( false )
) );
}
Adding new
files
Display a specific page or post
differently from all the rest.
You can make use of the template hierarchy to
display a specific page or post differently.
An ‘About page, with a slug of 'about', you can
create a ‘page-about.php’ file in the child
theme.
WooCommerce
Fix or enhance the WooCommerce in
your theme.
If the parent theme doesn’t fully support
WooCommerce, or you want to tweak how it
displays something, you can do this.
Let’s have a look at a quick example...
WooCommerce..
Change that button
Change "Return to shop"
text on empty cart to "Go
buy something already!"
WooCommerce..
Change that button
wp-content/plugins/
woocommerce/
templates/
cart/
cart-empty.php
is copied to
wp-content/themes/
child-theme/
woocommerce/
cart/
cart-empty.php
How does it all work?
Photo: https://flic.kr/p/muJmAv by Christina T.
Find the file
Template directory & stylesheet
directory
First some terms:
● Template directory = parent theme
directory
● Stylesheet directory = child theme
directory
Find the file
Search order
WordPress searches for the
appropriate file in the child theme
directory, then the parent theme
directory.
For a page, slug ‘about’, ID 2 it will
look in:
child-theme/page-about.php
parent-theme/page-about.php
child-theme/page-2.php
parent-theme/page-2.php
child-theme/page.php
parent-theme/page.php
The child theme always wins!
Beyond CSS and page templates
functions.php
Much more control … if you are
comfortable with php.
functions.php is run
automatically after all the
active plugins have been
loaded.
The child theme’s
functions.php runs
directly before the parent
theme’s functions.php.
functions.php...
Override the parent theme
A well written theme, like
Twenty Fifteen, will run its
code at the correct time,
using the appropriate
actions.
You can override these by
changing the priority in
add_action()
functions.php...
Correct the stylesheet loading.
Twenty Fifteen does not
load the stylesheet correctly.
It only loads the child
theme’s spreadsheet.
We can use @import or
redo the loading.
functions.php...
Correct the stylesheet loading… the fix
We run our code after the
parent theme. The code
unloads the child theme
stylesheet and then reloads
it, making the child theme
stylesheet depend on the
parent theme’s file and so
loads after it in the html.
Correct the stylesheet loading...
add_action( 'wp_enqueue_scripts', 'ct_styles', 11 );
function ct_styles() {
wp_dequeue_style( 'twentyfifteen-style' );
wp_enqueue_style( 'twentyfifteen-style',
get_template_directory_uri() .
'/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_uri(),
array('twentyfifteen-style') );
}
Or: http://justintadlock.com/archives/2014/11/03/loading-parent-styles-for-child-themes
What about bad parents
Photo: https://flic.kr/p/7Rdiq6 by IZATRINI.com
Bad parent
themes
Sometimes they do it their way … the
wrong way
Most themes on
wordpress.org get the basics
right but you may find
exceptions. Example:
wp_head();
echo '<link
src="/path/to/".$colour.".css">';
Bad parent
themes
This stylesheet cannot be
overloaded without editing
header.php.
Ideally it should be loaded
via the
‘wp_enqueue_scripts’
action. Report it to the
developer!
Bad parent
themes
Allow child themes to override all files.
A theme may include other
files that a child theme would
like to override e.g. image
files or javascript files.
Example:
wp_enqueue_scripts('cool-stuff',
get_template_directory_uri() . '/js/cool.js',
array( 'jquery' ) );
Bad parent
themes
Use get_theme_file_uri()
Twenty Fifteen hardcodes the
js/html5.js file instead of using this
technique.
We have to wp_dequeue_script()
and wp_enqueue_script() to load
our version. A fix...
wp_enqueue_scripts('cool-stuff',
get_theme_file_uri( '/js/cool.js'
),
array( 'jquery' ) );
Summary - Child themes are great
● Simple to create.
● Changes are not lost when parent theme
updated.
● You can change as much or as little as you
need.
Thanks!
Questions and Corrections to:
Damien Carbery
damien@damiencarbery.com
http://www.damiencarbery.com
@daymobrew
Photo: Mine

Contenu connexe

Tendances

Intro to WordPress Child Themes
Intro to WordPress Child ThemesIntro to WordPress Child Themes
Intro to WordPress Child Themes
vegasgeek
 
5 Tips for Writing Better JavaScript
5 Tips for Writing Better JavaScript5 Tips for Writing Better JavaScript
5 Tips for Writing Better JavaScript
Nael El Shawwa
 
How to use to build a website using WordPress: For normal people
How to use to build a website using WordPress: For normal peopleHow to use to build a website using WordPress: For normal people
How to use to build a website using WordPress: For normal people
Tris Hussey
 

Tendances (20)

WordPress Management & Marketing Tools
WordPress Management & Marketing ToolsWordPress Management & Marketing Tools
WordPress Management & Marketing Tools
 
Webinar: On-Page SEO Tips and Tricks
Webinar: On-Page SEO Tips and TricksWebinar: On-Page SEO Tips and Tricks
Webinar: On-Page SEO Tips and Tricks
 
Webinar: Myths, Mistakes and Management of WooCommerce at Scale
Webinar: Myths, Mistakes and Management of WooCommerce at ScaleWebinar: Myths, Mistakes and Management of WooCommerce at Scale
Webinar: Myths, Mistakes and Management of WooCommerce at Scale
 
WordCamp Bournemouth 2014 - Designing with data in WordPress
WordCamp Bournemouth 2014 - Designing with data in WordPressWordCamp Bournemouth 2014 - Designing with data in WordPress
WordCamp Bournemouth 2014 - Designing with data in WordPress
 
WordCamp Birmingham 2015 - Theme building tricks of the trade
WordCamp Birmingham 2015 - Theme building tricks of the tradeWordCamp Birmingham 2015 - Theme building tricks of the trade
WordCamp Birmingham 2015 - Theme building tricks of the trade
 
WordCamp Sheffield 2014 Theme Workflow Presentation
WordCamp Sheffield 2014 Theme Workflow PresentationWordCamp Sheffield 2014 Theme Workflow Presentation
WordCamp Sheffield 2014 Theme Workflow Presentation
 
Build an App with JavaScript and jQuery - LA - July 27
Build an App with JavaScript and jQuery - LA - July 27Build an App with JavaScript and jQuery - LA - July 27
Build an App with JavaScript and jQuery - LA - July 27
 
The Child Theme Dilemma (EN) - Milano Edition
The Child Theme Dilemma (EN) - Milano EditionThe Child Theme Dilemma (EN) - Milano Edition
The Child Theme Dilemma (EN) - Milano Edition
 
Intro to WordPress Child Themes
Intro to WordPress Child ThemesIntro to WordPress Child Themes
Intro to WordPress Child Themes
 
WooCommerce snippets
WooCommerce snippetsWooCommerce snippets
WooCommerce snippets
 
Build an App with JavaScript & jQuery
Build an App with JavaScript & jQuery Build an App with JavaScript & jQuery
Build an App with JavaScript & jQuery
 
How to Sell ANYTHING with WordPress + WooCommerce
How to Sell ANYTHING with WordPress + WooCommerceHow to Sell ANYTHING with WordPress + WooCommerce
How to Sell ANYTHING with WordPress + WooCommerce
 
Child Theme
Child ThemeChild Theme
Child Theme
 
Word press 3 @ wordcamp
Word press 3 @ wordcampWord press 3 @ wordcamp
Word press 3 @ wordcamp
 
10 PHP Snippets to Increase WooCommerce Sales
10 PHP Snippets to Increase WooCommerce Sales10 PHP Snippets to Increase WooCommerce Sales
10 PHP Snippets to Increase WooCommerce Sales
 
Teaching Your Clients How to Use WordPress
Teaching Your Clients How to Use WordPressTeaching Your Clients How to Use WordPress
Teaching Your Clients How to Use WordPress
 
Wp and jq
Wp and jqWp and jq
Wp and jq
 
Professional WordPress Workflow - WPDay 2015
Professional WordPress Workflow - WPDay 2015 Professional WordPress Workflow - WPDay 2015
Professional WordPress Workflow - WPDay 2015
 
5 Tips for Writing Better JavaScript
5 Tips for Writing Better JavaScript5 Tips for Writing Better JavaScript
5 Tips for Writing Better JavaScript
 
How to use to build a website using WordPress: For normal people
How to use to build a website using WordPress: For normal peopleHow to use to build a website using WordPress: For normal people
How to use to build a website using WordPress: For normal people
 

Similaire à Child Themes - WordCamp Dublin 2017

WordPress Child Themes
WordPress Child ThemesWordPress Child Themes
WordPress Child Themes
rfair404
 
Week 9 - Introduction to Child Themes
Week 9  - Introduction to Child ThemesWeek 9  - Introduction to Child Themes
Week 9 - Introduction to Child Themes
henri_makembe
 
WordPress Child Themes
WordPress Child ThemesWordPress Child Themes
WordPress Child Themes
openchamp
 
Meetup child-themes
Meetup child-themesMeetup child-themes
Meetup child-themes
DaisyOlsen
 
Meetup child-themes
Meetup child-themesMeetup child-themes
Meetup child-themes
DaisyOlsen
 

Similaire à Child Themes - WordCamp Dublin 2017 (20)

Child Themes (WordCamp Dublin 2017) with notes
Child Themes (WordCamp Dublin 2017) with notesChild Themes (WordCamp Dublin 2017) with notes
Child Themes (WordCamp Dublin 2017) with notes
 
Child Themes in WordPress
Child Themes in WordPressChild Themes in WordPress
Child Themes in WordPress
 
WordPress HTML, CSS & Child Themes
WordPress HTML, CSS & Child ThemesWordPress HTML, CSS & Child Themes
WordPress HTML, CSS & Child Themes
 
WordPress Child Themes
WordPress Child ThemesWordPress Child Themes
WordPress Child Themes
 
Customizing WordPress Themes
Customizing WordPress ThemesCustomizing WordPress Themes
Customizing WordPress Themes
 
The Child Theme Dilemma (EN)
The Child Theme Dilemma (EN)The Child Theme Dilemma (EN)
The Child Theme Dilemma (EN)
 
Week 9 - Introduction to Child Themes
Week 9  - Introduction to Child ThemesWeek 9  - Introduction to Child Themes
Week 9 - Introduction to Child Themes
 
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 ...
 
WordPress Child Themes
WordPress Child ThemesWordPress Child Themes
WordPress Child Themes
 
Meetup child-themes
Meetup child-themesMeetup child-themes
Meetup child-themes
 
Meetup child-themes
Meetup child-themesMeetup child-themes
Meetup child-themes
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
Intro to WordPress Child Themes (NERDS Sept 2014)
Intro to WordPress Child Themes (NERDS Sept 2014)Intro to WordPress Child Themes (NERDS Sept 2014)
Intro to WordPress Child Themes (NERDS Sept 2014)
 
Meetup child-themes
Meetup child-themesMeetup child-themes
Meetup child-themes
 
WordPress Child Themes: The what. The why. The how.
WordPress Child Themes: The what. The why. The how.WordPress Child Themes: The what. The why. The how.
WordPress Child Themes: The what. The why. The how.
 
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
Introduction to WordPress Child Theming, WordCamp Kansas City, 2015
 
Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015
 
Best practices in WordPress Development
Best practices in WordPress DevelopmentBest practices in WordPress Development
Best practices in WordPress Development
 
wp-n00b.php
wp-n00b.phpwp-n00b.php
wp-n00b.php
 
Theme Kickstart
Theme KickstartTheme Kickstart
Theme Kickstart
 

Dernier

Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Lisi Hocke
 

Dernier (20)

Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...
Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...
Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with Links
 
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
 
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AI
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
 
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
 
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
 
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
Auto Affiliate  AI Earns First Commission in 3 Hours..pdfAuto Affiliate  AI Earns First Commission in 3 Hours..pdf
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
 
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdfThe Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
 
Spring into AI presented by Dan Vega 5/14
Spring into AI presented by Dan Vega 5/14Spring into AI presented by Dan Vega 5/14
Spring into AI presented by Dan Vega 5/14
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In harare
^Clinic ^%[+27788225528*Abortion Pills For Sale In harare^Clinic ^%[+27788225528*Abortion Pills For Sale In harare
^Clinic ^%[+27788225528*Abortion Pills For Sale In harare
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements Engineering
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In witbank
^Clinic ^%[+27788225528*Abortion Pills For Sale In witbank^Clinic ^%[+27788225528*Abortion Pills For Sale In witbank
^Clinic ^%[+27788225528*Abortion Pills For Sale In witbank
 
Lessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfLessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdf
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea Goulet
 

Child Themes - WordCamp Dublin 2017

  • 1. Child Themes Won’t someone think of the children? By Damien Carbery Photo: https://flic.kr/p/ccHYYL by Justkids
  • 2. Intro - What's the problem? Editing core files is bad. Editing themes is bad. Child themes are easy.
  • 3. Why do you need a child theme?
  • 4. Perfect … Except for just one thing A child theme can help. Photo: https://flic.kr/p/4bnRok by m.a.r.c.
  • 5. Let’s create a child theme
  • 6. Just one file /* Name: Child Theme Template: twentyfifteen */ That’s it. Done. Now go Activate it.
  • 7. What can you do now? ● Change the styles ● Change the layout of posts, pages, archives or individual ones ● Add new features e.g. add support for WooCommerce
  • 8. Changing styles This is the simplest, least technical thing that you can do.
  • 9. Changing styles Change the page font from “Noto Serif” to Arial: body { font-family: Arial, serif; }
  • 11. Changing styles Change the header colours from #333 to red: h1, h2, h3, h4, h5, h6 { color: #f00; }
  • 13. Changing styles Change ul marker from disc to a circle: ul { list-style: circle; }
  • 16. Beyond style changes You can copy a file from the parent theme and modify it. Twenty Fifteen displays the full post content on archive pages. Let’s change it to show excerpts.
  • 17. Excerpts in Archives Copy the template file and make your change. archive.php displays the archive. It uses content.php. That calls the_content() so change it to the_excerpt()
  • 18. Excerpts in Archives .... You have to edit carefully and check your work. Now test the change - oops, single pages, single posts are showing excerpts. The fix: The code will be: if (is_archive() ) { the_excerpt(); } else { the_content( sprintf( 'Continue reading %s', the_title( false ) ) ); }
  • 19. Adding new files Display a specific page or post differently from all the rest. You can make use of the template hierarchy to display a specific page or post differently. An ‘About page, with a slug of 'about', you can create a ‘page-about.php’ file in the child theme.
  • 20. WooCommerce Fix or enhance the WooCommerce in your theme. If the parent theme doesn’t fully support WooCommerce, or you want to tweak how it displays something, you can do this. Let’s have a look at a quick example...
  • 21. WooCommerce.. Change that button Change "Return to shop" text on empty cart to "Go buy something already!"
  • 22. WooCommerce.. Change that button wp-content/plugins/ woocommerce/ templates/ cart/ cart-empty.php is copied to wp-content/themes/ child-theme/ woocommerce/ cart/ cart-empty.php
  • 23. How does it all work? Photo: https://flic.kr/p/muJmAv by Christina T.
  • 24. Find the file Template directory & stylesheet directory First some terms: ● Template directory = parent theme directory ● Stylesheet directory = child theme directory
  • 25. Find the file Search order WordPress searches for the appropriate file in the child theme directory, then the parent theme directory. For a page, slug ‘about’, ID 2 it will look in: child-theme/page-about.php parent-theme/page-about.php child-theme/page-2.php parent-theme/page-2.php child-theme/page.php parent-theme/page.php The child theme always wins!
  • 26. Beyond CSS and page templates
  • 27. functions.php Much more control … if you are comfortable with php. functions.php is run automatically after all the active plugins have been loaded. The child theme’s functions.php runs directly before the parent theme’s functions.php.
  • 28. functions.php... Override the parent theme A well written theme, like Twenty Fifteen, will run its code at the correct time, using the appropriate actions. You can override these by changing the priority in add_action()
  • 29. functions.php... Correct the stylesheet loading. Twenty Fifteen does not load the stylesheet correctly. It only loads the child theme’s spreadsheet. We can use @import or redo the loading.
  • 30. functions.php... Correct the stylesheet loading… the fix We run our code after the parent theme. The code unloads the child theme stylesheet and then reloads it, making the child theme stylesheet depend on the parent theme’s file and so loads after it in the html.
  • 31. Correct the stylesheet loading... add_action( 'wp_enqueue_scripts', 'ct_styles', 11 ); function ct_styles() { wp_dequeue_style( 'twentyfifteen-style' ); wp_enqueue_style( 'twentyfifteen-style', get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_uri(), array('twentyfifteen-style') ); } Or: http://justintadlock.com/archives/2014/11/03/loading-parent-styles-for-child-themes
  • 32. What about bad parents Photo: https://flic.kr/p/7Rdiq6 by IZATRINI.com
  • 33. Bad parent themes Sometimes they do it their way … the wrong way Most themes on wordpress.org get the basics right but you may find exceptions. Example: wp_head(); echo '<link src="/path/to/".$colour.".css">';
  • 34. Bad parent themes This stylesheet cannot be overloaded without editing header.php. Ideally it should be loaded via the ‘wp_enqueue_scripts’ action. Report it to the developer!
  • 35. Bad parent themes Allow child themes to override all files. A theme may include other files that a child theme would like to override e.g. image files or javascript files. Example: wp_enqueue_scripts('cool-stuff', get_template_directory_uri() . '/js/cool.js', array( 'jquery' ) );
  • 36. Bad parent themes Use get_theme_file_uri() Twenty Fifteen hardcodes the js/html5.js file instead of using this technique. We have to wp_dequeue_script() and wp_enqueue_script() to load our version. A fix... wp_enqueue_scripts('cool-stuff', get_theme_file_uri( '/js/cool.js' ), array( 'jquery' ) );
  • 37. Summary - Child themes are great ● Simple to create. ● Changes are not lost when parent theme updated. ● You can change as much or as little as you need.
  • 38. Thanks! Questions and Corrections to: Damien Carbery damien@damiencarbery.com http://www.damiencarbery.com @daymobrew Photo: Mine