Many WordPress tutorials suggest, that you need a Child Theme to customize the layout of your website.
While you should never modify WordPress core nor WordPress themes themselves, this session shows common pitfalls of Child Themes and provides you with save and efficient alternatives.
2. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
Bego Mario Garde
Happy WordPress user since 7 years
Moderator in German support forums
General Translation Editor
… and this is my first WordCamp session!
3. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
Some general assumptions
Don't hack WordPress Core. Never.
Reasons: Updates overwrite your changes
Your site gets unmaintainable
Difficult to provide support
4. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
Some general assumptions
Don't hack WordPress Themes.
Reasons: Updates overwrite your changes
Your theme gets unmaintainable
Difficult to provide support
5. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
The obvious solution
Create a Child Theme!
Reason: Updates don't overwrite your changes.
Changes are easy to spot.
6. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
The obvious solution
Create a Child Theme!
Reason: Updates don't overwrite your changes.
Changes are easy to spot.
Well, sort of.
7. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
.php .js .css
Child Theme
What about security issues?
.php .js .css
Parent Theme
.php
We copy templates of a Parent
Theme into the Child Theme and
tweak them as needed.
But what, if the Parent Theme had
a bug or even security issues?
The Child Theme Dilemma, T. Landsiedel
http://bit.ly/1SWpJFZ
8. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
.php .js .css
Child Theme
What about security issues?
.php
.js .css
Parent Theme
.php
We copy templates of a Parent
Theme into the Child Theme and
tweak them as needed.
But what, if the Parent Theme had
a bug or even security issues?
The Child Theme Dilemma, T. Landsiedel
http://bit.ly/1SWpJFZ
9. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
.php .js .css
Child Theme
What about security issues?
.php
.js .css
Parent Theme
.php
While the Parent Theme gets
fixed by the theme developer,
… the Child Theme keeps the bug.
(worst case: you don't even notice)
The Child Theme Dilemma, T. Landsiedel
http://bit.ly/1SWpJFZ
10. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
.php .js .css
Child Theme
What about security issues?
.php
.js .css
Parent Theme
.php.php
While the Parent Theme gets
fixed by the theme developer,
… the Child Theme keeps the bug.
(worst case: you don't even notice)
The Child Theme Dilemma, T. Landsiedel
http://bit.ly/1SWpJFZ
11. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
.php .js .css
Child Theme
Other issues?
.php
.js .css
Parent Theme
.php.php
Theme developers may change
function and class names.
Worst Case: Your website shows
an error message. Only.
(That's when your client calls!)
The Child Theme Dilemma, T. Landsiedel
http://bit.ly/1SWpJFZ
15. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
Plugin Child Theme Check
Great idea, great tool, but …
Theme Review Team not convinced
about version numbers in templates
Changes still hard to maintain
16. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
More sites, more Child Themes
Things get a little messy,
if you create a new Child Theme
for every new client.
How do you manage all of them
after two months? After two years?
26. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
Right Click ➞
Inspect Element
Try any value
Copy best result
Developer Tools
Chrome Developer Tools
https://developer.chrome.com/devtools
28. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
Support for SASS
Add-on or
Replacement
Revisions
Disables on
syntax errors
Jetpack
Plugin Jetpack
https://wordpress.org/plugins/jetpack/
29. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
One Trick Pony
Easy and reliable
No revisions
No support for
SASS
Simple
Custom CSS
Plugin Simple Custom CSS
https://wordpress.org/plugins/simple-custom-css/
30. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
Need to style
individual pages?
No Problem!
WordPress adds
the right body
Class
body Class
WP Codex: Function Reference/body class
http://bit.ly/1seFLBw
31. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
Need to style
individual pages?
No Problem!
WordPress adds
the right body
Class
body Class
WP Codex: Function Reference/body class
http://bit.ly/1seFLBw
33. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
Additional editor to
add any function
for front or back
end
Functions can be
exported
Error handling
Code Snippets
Plugin Code Snippets
https://wordpress.org/plugins/code-snippets/
39. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
Plugin Code Snippets
https://wordpress.org/plugins/code-snippets/
Hooks
to the rescue
Need to add a
custom field?
You don't need
custom templates.
46. Bego Mario Garde
@pixolin
jQuery(document).ready(function($){
$('#smoothup').on('click', function(){
$('html, body').animate({scrollTop:0}, 'fast');
return false;
});
});
add_action('twentysixteen_credits', 'scroll_up_link');
function scroll_up_link() {
echo '<a href="#" id="smoothup" class="siteinfo"
title="Back to top">Back to Top / </a>';
}
WordCamp Antwerp 2016
in plugin Code Snippets
in plugin Custom JS Editor
47. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
Step 6
Performance matters
Concatenate JavaScript and CSS
48. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
Autoptimize
Aggregates and
minimizes JS,
CSS and HTML
Plugin Autoptimize
https://wordpress.org/plugins/autoptimize/
51. WordCamp Antwerp 2016
Bego Mario Garde
@pixolin
Is it wrong to use Child Themes?
Is it evil to use Child Themes?
No.
But you may have better alternatives.
Dank u wel · Merci