Table of Contents
Creating a Child Theme #
A child theme in WordPress is a theme that inherits the functionality and styling of another theme, called the parent theme. Child themes are the recommended way of modifying an existing theme.
Why Use a Child Theme? #
- Preserve Customizations: Customizations made to a child theme are kept separate from the parent theme, so they are not lost when the parent theme is updated.
- Safe Updates: You can update the parent theme without overwriting your changes.
- Extend Functionality: Add custom functionality and styles to the parent theme.
Using the Provided Child Theme #
To ensure that your customizations are safe and won’t be lost during updates, we provide a pre-built child theme in our theme package. Follow these steps to install and activate the child theme:
Step 1: Download the Theme Package #
- Download the Package:
- Download the theme package from [your website or marketplace].
Step 2: Unzip the Package #
- Unzip the Package:
- Unzip the downloaded package. Inside, you will find folders for the parent theme and the child theme.
Step 3: Install the Parent Theme #
- Log in to Your WordPress Admin Panel:
- Go to
yourdomain.com/wp-admin
and log in.
- Go to
- Navigate to Appearance > Themes:
- Click on “Add New” and then “Upload Theme”.
- Upload and Install the Parent Theme:
- Click on “Choose File” and select the parent theme ZIP file (e.g.,
yourtheme.zip
). - Click “Install Now” and then “Activate”.
- Click on “Choose File” and select the parent theme ZIP file (e.g.,
Step 4: Install the Child Theme #
- Navigate to Appearance > Themes:
- Click on “Add New” and then “Upload Theme”.
- Upload and Install the Child Theme:
- Click on “Choose File” and select the child theme ZIP file (e.g.,
yourtheme-child.zip
). - Click “Install Now” and then “Activate”.
- Click on “Choose File” and select the child theme ZIP file (e.g.,
Step 5: Activate the Child Theme #
- Activate the Child Theme:
- Once the child theme is installed, go to
Appearance > Themes
. - Find the child theme (e.g.,
Your Theme Child
) and click “Activate”.
- Once the child theme is installed, go to
Customizing the Child Theme #
With the child theme activated, you can safely add customizations:
- Adding Custom CSS:
- Go to
Appearance > Theme File Editor
. - Select
style.css
under the child theme and add your custom CSS.
- Go to
- Overriding Parent Theme Templates:
- To override a template file, copy the file from the parent theme to the child theme, maintaining the same file structure. For example, to override
header.php
, copy it to the child theme directory.
- To override a template file, copy the file from the parent theme to the child theme, maintaining the same file structure. For example, to override
Additional Information #
- Child Theme Structure:
- The child theme includes a basic
style.css
andfunctions.php
to enqueue styles and scripts properly. - You can add more files and customize them as needed.
- The child theme includes a basic
- Maintaining Customizations:
- Always make changes in the child theme to ensure they are not lost during parent theme updates.
Example Child Theme Files #
style.css
/*
Theme Name: Your Theme Child
Theme URI: http://example.com/your-theme-child/
Description: A child theme of the Your Theme theme
Author: Your Name
Author URI: http://example.com
Template: yourtheme
Version: 1.0.0
Text Domain: yourtheme-child
*/
/* Add your custom styles below this line */
functions.php
<?php
function yourtheme_child_enqueue_styles() {
// Enqueue parent theme styles
wp_enqueue_style('yourtheme-style', get_template_directory_uri() . '/style.css');
// Enqueue child theme styles
wp_enqueue_style('yourtheme-child-style', get_stylesheet_directory_uri() . '/style.css', array('yourtheme-style'));
}
add_action('wp_enqueue_scripts', 'yourtheme_child_enqueue_styles');
?>
Conclusion #
Using the provided child theme ensures that your customizations are safe from updates to the parent theme. Follow the steps outlined above to install and activate the child theme, and start customizing your site without worry.