Skip to content

Included in Free

Use a child theme for any change that goes beyond the Customizer, so theme updates never overwrite your work. Everything below works the same on a site with one product or many.

Create a folder knowx-child in wp-content/themes with two files.

style.css:

/*
Theme Name: KnowX Child
Template: knowx
Version: 1.0.0
*/

functions.php:

<?php
add_action( 'wp_enqueue_scripts', function () {
wp_enqueue_style( 'knowx-child', get_stylesheet_uri(), array( 'knowx-global' ), '1.0.0' );
} );

Activate it under Appearance > Themes. Customizer values are stored per theme, so copy the parent’s settings to the child once (see Move the Customizer settings).

Goal How
Colours, radius, shadows Override the CSS variables in your stylesheet. See Styling, tokens and assets.
The markup of a page or a part Copy the file to the same path in the child theme. See Templates and template parts.
Behaviour (schema, limits, palettes, breadcrumbs) Add a filter. See the Hooks reference.
Content to add above or below the page knowx_before_content, knowx_after_content, knowx_sub_header.
A new block pattern Add a file to the child theme’s patterns folder.
A default Customizer value Filter knowx_customizer_field_args.

Change the brand colour for the whole site

Section titled “Change the brand colour for the whole site”
:root {
--color-theme-primary: #0a7;
}

A colour set in the Customizer wins over the variable in your stylesheet, because the theme prints the owner’s choice after the defaults. Leave the Customizer Theme Color at its default if the child theme sets it.

Copy template-parts/docs/help.php to knowx-child/template-parts/docs/help.php and change the text or markup. Keep the functions it calls. When the parent theme changes that file in an update, compare your copy against the new version: that is the price of a copy, and the reason to prefer a hook where one exists.

add_action( 'wp_enqueue_scripts', function () {
wp_enqueue_script( 'knowx-child-app', get_stylesheet_directory_uri() . '/app.js', array(), '1.0.0', array( 'strategy' => 'defer', 'in_footer' => true ) );
} );
add_action( 'wp_enqueue_scripts', function () {
if ( is_category() || is_singular( 'post' ) ) {
wp_enqueue_style( 'knowx-child-docs', get_stylesheet_directory_uri() . '/docs.css', array( 'knowx-global' ), '1.0.0' );
}
} );

Move the Customizer settings to the child theme

Section titled “Move the Customizer settings to the child theme”

WordPress stores Customizer values separately for each theme. After you activate the child theme, copy the parent’s values once:

Terminal window
wp eval 'update_option( "theme_mods_knowx-child", get_option( "theme_mods_knowx" ) );'

Use your child theme’s folder name in place of knowx-child. Without a copy, every setting shows its default until you publish it again in Appearance > Customize.

The text domain is knowx. Use it in strings that you add to copied template parts so the existing translation files keep working. The translation template is languages/knowx.pot.

The 1.x template tag knowx_get_breadcrumb( $display = true ) still works but is deprecated: use knowx_the_breadcrumb() to print the trail. Many other 1.7 functions were internal callbacks of features that were removed in 2.0 (the login page, the plugin recommendations, the web font loader and the Kirki integration); child themes that called them directly need to drop those calls.

  1. Test the update on a staging copy.
  2. Compare each template file you copied with the new parent file (diff or your editor).
  3. Check the Functions reference for any helper your child theme calls.