How to make a daughter theme WordPress

Create a child theme for WordPress in minutes w/ example: copy & activate the parent theme, create a new style.css & functions.php files.

Creating a WordPress Child Theme from Scratch

Creating a WordPress child theme is an effective way to customize a WordPress theme without affecting the original code. A WordPress child theme allows you to customize the design, functions, and features of a WordPress theme without modifying the original code. It’s a great way to make sure you don’t lose your changes when the original theme is updated.

Here’s a step-by-step guide to creating a WordPress child theme:

Step 1: Choose a Parent Theme

The first step in creating a WordPress child theme is to choose a parent theme. A parent theme is the original theme that you are going to base your child theme on. The parent theme should be a theme that is regularly updated and supported by the developer. It should also be a theme that meets your needs in terms of design and features.

Step 2: Create the Child Theme Folder

Once you’ve chosen a parent theme, you can begin creating the child theme folder. The child theme folder should be created in the “/wp-content/themes/” directory. The name of the folder should be unique and should include the word “child” in the name. For example, if the parent theme is called “example_theme”, the child theme folder should be named “example_theme-child”.

Step 3: Create the style.css File

Once you’ve created the child theme folder, you’ll need to create a style.css file within the folder. The style.css file is the main stylesheet of your child theme. It will be used to override the styles of the parent theme. The style.css file should include the following code:

/*
Theme Name: Example Theme Child
Theme URI: http://example.com
Description: A child theme of Example Theme
Author: Your Name
Author URI: http://yoursite.com
Template: example_theme
Version: 1.0.0
*/

/* =Theme customization starts here
-------------------------------------------------------------- */

/* Add your custom CSS here */

The “Template” line in the code should match the name of the parent theme’s folder. The “Version” line should be set to 1.0.0. The “Theme Name”, “Theme URI”, “Description”, “Author”, and “Author URI” lines should be filled in with your own information.

Step 4: Create the functions.php File

The next step is to create a functions.php file. The functions.php file is where you can add additional PHP code to your child theme. The functions.php file should include the following code:

<?php

// Enqueue parent theme style
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}

// Add your custom functions here

?>

The code in this file will make sure that the parent theme’s style.css file is used in the child theme. This will allow you to override the styles of the parent theme. You can add additional code to the functions.php file to customize the functionality of your child theme.

Step 5: Activate the Child Theme

Once you’ve created the child theme folder, style.css file, and functions.php file, you can activate the child theme. To activate the child theme, go to the WordPress dashboard and select “Appearance” > “Themes”. You should see your child theme listed. Click “Activate” to activate the child theme.

Step 6: Customize the Child Theme

Now that your child theme is activated, you can start customizing it. You can add new styles to the style.css file, add custom functions to the functions.php file, and add custom templates. You can also use plugins to add additional features to the child theme.

Creating a WordPress child theme is an effective way to customize a WordPress theme without affecting the original code. By following the steps outlined above, you can create a WordPress child theme from scratch and customize it to meet your needs.

Answers (0)