Skip to content
Docs

Create a Stax child theme

A child theme keeps your code changes separate from Stax, so a theme update does not overwrite them. You need one only if you add PHP, template files or a larger stylesheet. For a few lines of CSS, Appearance > Customize > Additional CSS is enough.

  1. Download stax-child.zip.
  2. Go to Appearance > Themes > Add New Theme and click Upload Theme.
  3. Choose the zip file and click Install Now.
  4. Click Activate.

The Stax theme must stay installed: the child theme loads it as its parent.

  1. On your computer, create a folder named stax-child.

  2. In that folder, create a file named style.css with this header:

    /*
    Theme Name: Stax Child
    Template: stax
    Version: 1.0.0
    Text Domain: stax-child
    */

    Template: stax is the folder name of the parent theme and must match exactly.

  3. Create a file named functions.php that loads the child stylesheet after the theme styles:

    <?php
    add_action( 'wp_enqueue_scripts', 'stax_child_enqueue_styles' );
    function stax_child_enqueue_styles() {
    wp_enqueue_style(
    'stax-child',
    get_stylesheet_uri(),
    array( 'stax-global' ),
    wp_get_theme()->get( 'Version' )
    );
    }

    stax-global is the handle of the main Stax stylesheet, so your CSS is printed after it and can override it.

  4. Upload the stax-child folder to wp-content/themes over FTP, or zip it and upload it from Appearance > Themes > Add New Theme > Upload Theme.

  5. Go to Appearance > Themes and click Activate on Stax Child.

Move your Customizer settings to the child theme

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

WordPress stores Customizer settings per theme, so a newly activated child theme starts with the default settings. To copy them over:

  1. Install Customizer Export/Import while the parent theme is still active.
  2. Export the settings from the Customizer.
  3. Activate the child theme and import the file.

See Export and import for the steps.

  • CSS: add it to the child style.css.
  • PHP: add functions and hooks to the child functions.php. It runs in addition to the parent file, not instead of it.
  • Templates: copy a template file from wp-content/themes/stax to the same relative path in stax-child and edit the copy. WordPress loads the child version first.