How do themes provide support for child themes?

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?


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.

Leave a Comment