Working with Child Themes
Utsav singh @rathour
Blogs at: http://codepixelz.com
(@codepixelzmedia)
Dev @ Jasper IT Solution...
Because we should.

Why way to theme
bother?
Better
Automattic recommends.
Next developer will thank you.
Bother to Explain?
Of course Not
That is why I am here.
A quick survey:
Who among here...
• Understands what a child theme is?
• has created and used child themes?
Scenario #1
Scenario #2
Let me make some crazy changes to the
theme code.
Oh wow! An Update. *clickity click*
Been there before?
How does it feel?
Enter: Child Theme
• Inherits the functionality of parent theme
• Allows you to:
- Modify Parent theme
- Add Features to t...
Like Father Like Son
Like Father Like Son
Is just like the parent.

A little modification here and there
A little features added here and there
Changes are lost while updating, parent theme
Why use Child Theme?
Speeds up Development Process
Overrides the parts of pa...
Great another week or two of
learning 

Nope, this is easier than most of you have
thought it would be.
This is moreover ...
How to create a Child Theme?
How to create a Child Theme?
How to create a Child Theme?
Create style.css inside the folder and add this
/*
Theme Name: Twenty Thirteen Child Theme
UR...
How to create a Child Theme?
How to create a Child Theme?

Why this Kolaveri D?
@import url("../twentythirteen/style.css");
Go Ahead, make CSS changes that you wanted
What next?
to make.
Customize
But I have more than just CSS to
change
Working with Templates

Simply create a file with same name and it
overwrites same file from Parent theme

Eg: header.php ...
Working with Templates
• Parent’s header.php
wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu'...
Including a File
• require_once( get_stylesheet_directory() . '/my_included_file.php' );
why get_stylesheet_directory()?
B...
Handling Functions
• Child’s, functions.php is loaded before
Parent’s functions.php
• you can make the user functions repl...
Handling Functions

Make sure your parent theme has functions defined
this way.
if ( ! function_exists( 'theme_special_nav...
But wait…
• Just because you can, doesn’t mean you should.
• Be wise: “Measure Twice, Cut Once”
• Almost anyone can become...
Good Parent and Bad Parent
• Good Parent's functions look like:
if ( ! function_exists( 'do_this' ) ) {
//Something here
}...
When not to use Child theme?
• When you are creating a theme and know, you won’t
update
• Using a theme that never updates...
Go Ahead! Experiment!
Find more at: http://codex.wordpress.org/Child_Themes
Questions?
What are child themes, and why use them
What are child themes, and why use them
What are child themes, and why use them
What are child themes, and why use them
Upcoming SlideShare
Loading in …5
×

What are child themes, and why use them

2,484 views

Published on

I talk about what a child theme is in wordpress and what are its use, when is it best to use Child theme and how you can be a good person using child theme and choosing the right parent theme for your project.

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,484
On SlideShare
0
From Embeds
0
Number of Embeds
165
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

What are child themes, and why use them

  1. 1. Working with Child Themes Utsav singh @rathour Blogs at: http://codepixelz.com (@codepixelzmedia) Dev @ Jasper IT Solutions
  2. 2. Because we should. Why way to theme bother? Better Automattic recommends. Next developer will thank you.
  3. 3. Bother to Explain? Of course Not That is why I am here.
  4. 4. A quick survey: Who among here... • Understands what a child theme is? • has created and used child themes?
  5. 5. Scenario #1
  6. 6. Scenario #2 Let me make some crazy changes to the theme code. Oh wow! An Update. *clickity click*
  7. 7. Been there before? How does it feel?
  8. 8. Enter: Child Theme • Inherits the functionality of parent theme • Allows you to: - Modify Parent theme - Add Features to the Parent theme • Safest and easiest way to modify
  9. 9. Like Father Like Son
  10. 10. Like Father Like Son Is just like the parent. A little modification here and there A little features added here and there
  11. 11. Changes are lost while updating, parent theme Why use Child Theme? Speeds up Development Process Overrides the parts of parent theme that you specify, without actually changing the theme itself.
  12. 12. Great another week or two of learning  Nope, this is easier than most of you have thought it would be. This is moreover like any other theme.
  13. 13. How to create a Child Theme?
  14. 14. How to create a Child Theme?
  15. 15. How to create a Child Theme? Create style.css inside the folder and add this /* Theme Name: Twenty Thirteen Child Theme URI: http://codepixelz.com/twenty-thirteen-child/ Description: Twenty Thirteen Child Theme Author: Utsav Singh Rathour Author URI: http://codepixelz.com Template: twentythirteen Version: 1.0.0 */
  16. 16. How to create a Child Theme?
  17. 17. How to create a Child Theme? Why this Kolaveri D? @import url("../twentythirteen/style.css");
  18. 18. Go Ahead, make CSS changes that you wanted What next? to make. Customize
  19. 19. But I have more than just CSS to change
  20. 20. Working with Templates Simply create a file with same name and it overwrites same file from Parent theme Eg: header.php in child replaces parent’s header.php
  21. 21. Working with Templates • Parent’s header.php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); get_search_form(); • Child’s header.php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); //get_search_form();
  22. 22. Including a File • require_once( get_stylesheet_directory() . '/my_included_file.php' ); why get_stylesheet_directory()? Because get_template_directory() returns Parent themes path. • get_template_part( 'content', get_post_format() ); Note: It looks for say, content-video.php on child theme, if not found; before falling back to content.php on child. Searches for the file in parent.
  23. 23. Handling Functions • Child’s, functions.php is loaded before Parent’s functions.php • you can make the user functions replaceable by a child theme, by declaring them conditionally
  24. 24. Handling Functions Make sure your parent theme has functions defined this way. if ( ! function_exists( 'theme_special_nav' ) ) { function theme_special_nav() { // Do something. } }
  25. 25. But wait… • Just because you can, doesn’t mean you should. • Be wise: “Measure Twice, Cut Once” • Almost anyone can become a parent, but not all are good parents. And same applies for themes.
  26. 26. Good Parent and Bad Parent • Good Parent's functions look like: if ( ! function_exists( 'do_this' ) ) { //Something here } • Bad Parent's functions look like : function do_this(){ // Something here }
  27. 27. When not to use Child theme? • When you are creating a theme and know, you won’t update • Using a theme that never updates. • Because it is confusing to client. • Because it is a little slow.
  28. 28. Go Ahead! Experiment! Find more at: http://codex.wordpress.org/Child_Themes
  29. 29. Questions?

×