clear glass ball on brown sand during sunset

How to Correctly Setup WordPress Child Themes

Child themes allow for theme customization without tying the site down to a specific theme version. This means that your parent theme can be customized via the child, never losing customizations due to theme updates.

While some theme customization options are completely tied to the site’s database, if you customize PHP templates or CSS files, those files would get overwritten when your theme is updated. Always keep parent themes updated.

The manual way

  1. Create a new folder in the “wp-content/themes” directory of your WordPress installation and give it a unique name. This folder will contain the files for your child theme.
  2. Create a new file in this folder called “style.css” and paste the following code at the top of the file:
/*
 Theme Name: My child theme
 Template: parent-theme-name
*/

@import url("../parent-theme/style.css");

Replace “My child theme” with the desired name for your child theme and “parent-theme-name” with the name of the parent theme you want to use as the base for your child theme.

This style.css file is where you want to place any custom CSS styles.

  1. Create a new file in this folder called “functions.php” and paste the following code into it:
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );

function enqueue_parent_styles() {
   wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}

This code will ensure that the stylesheet of the parent theme is loaded first, followed by your child theme’s stylesheet.

  1. Log in to your WordPress dashboard, go to “Appearance > Themes,” and activate your new child theme.
  2. Start customizing your child theme by adding new styles and functionality to the “style.css” and “functions.php” files.

Note: It’s important to remember that when you update the parent theme, your customizations will not be affected. This is one of the benefits of using a child theme.

The automated (plugin way)

While I’m not so keen on suggesting a plugin for a task that doesn’t need a plugin, we’re always looking for automated, easier ways to do things — plus, once the plugin does its thing, it should be able to be removed from the site.

  1. Install the plugin. You can install the WordPress Child Theme Configurator plugin by going to the “Plugins > Add New” section of your WordPress dashboard and searching for “WordPress Child Theme Configurator.” Click “Install Now” and then “Activate” the plugin.
  2. Go to the “Appearance > Child Themes” section of your WordPress dashboard.
  3. Click on the “Create a new child theme” button.
  4. Select the parent theme you want to use as the base for your child theme.
  5. Fill out the form with the information for your child theme, including the child theme name, description, and author information.
  6. Click on the “Create Child Theme” button to generate the child theme files.
  7. Activate your new child theme. Go to the “Appearance > Themes” section of your WordPress dashboard and activate the child theme you just created.
  8. Start customizing your child theme. You can add custom styles to your child theme by going to the “Appearance > Editor” section of your WordPress dashboard and editing the “style.css” file.

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.