16

One of the requests on themeforest is that themes are required to provide child theme support.

I know what child themes are, although I haven't worked a lot with them, but I would like to know is there something that my theme must have to support child themes?

2
  • Was there a problem creating a child theme for your theme? If you know how to create a child theme then you should know everything there is to know?
    – Tom J Nowell
    Commented Aug 10, 2013 at 19:19
  • I created and it works fine, but I wonder if there is anything more that I need to add or test. If that's all than ok. Thanks!
    – Valeka
    Commented Aug 10, 2013 at 19:48

2 Answers 2

34

There is already an accepted answer, however, I am going to offer a different answer. There are things you need to do to support proper child theme functionality.

First and foremost, work within the WordPress template hierarchy. I have seen themes do strange things and cook up non-standard templating structures. It isn't even necessary to use any of the WordPress theme system to display content if you really really don't want to. Resist the urge to do any of that.

Second, load files that should be replaceable with get_template_part() and locate_template() and not with PHP's include or require. Files loaded with get_template_part() and locate_template() part can be replaced by child themes. Files loaded by include or require can't.

Third, use get_template_directory(), get_template_directory_uri(), get_stylesheet_directory(), and get_stylesheet_directory_uri() appropriately.

You probably also want to register and enqueue your scripts and stylesheets with wp_register_script, wp_enqueue_script, wp_register_style and wp_enqueue_style.

If you do those things the theme should be pretty pretty child-theme friendly.

Put another way, if you are doing things right in the first place you shouldn't have to do anything special to have a child-theme friendly theme.

5
  • 5
    Exactly. Nothing is more frustrating than working with a theme where styles, scripts and template parts can't be modified by a child theme. Commented Aug 10, 2013 at 23:17
  • @ s_ha_dum: well sexplained!
    – Tara
    Commented Aug 11, 2013 at 1:10
  • 2
    @Valeka: You should mark this answer as Accepted - such nicely explained by s_ha_dum. Kudos to him. Commented Nov 25, 2013 at 6:09
  • Actually I think include and require need to be used and get_template_directory() should be there inside of them, and child themes can modify files required, (or included). Can you please modify your answer a bit.
    – prosti
    Commented May 2, 2016 at 21:27
  • You didn't understand my answer @prosti
    – s_ha_dum
    Commented May 2, 2016 at 23:14
1

From my experience, nearly all themes should support a child theme. I've never had to do any thing specific to a parent theme to make it support a child theme. The WordPress Codex has a good overview of child themes. http://codex.wordpress.org/Child_Themes Hope this helps answer your question!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.