Child Themes
Child Themes & Designs
All designs are built into the main theme, there is no need to install extra child themes when getting started.
Child Themes & Custom Designs
Learn about child themes in PremiumPress, when to use them, and how to create one safely for custom modifications without losing your changes during theme updates.
Reading time: 10 minutes
What Are Child Themes?
A child theme is a sub-theme that inherits all functionality, features, and styling from its parent theme (your PremiumPress theme). It allows you to make modifications without editing the parent theme files directly.
How Child Themes Work
- Child theme sits on top of parent theme
- Inherits all parent theme features automatically
- Your custom files override parent theme files
- Parent theme updates don't affect your customizations
- Safe way to modify themes without breaking updates
Key Concepts
| Term | Definition |
|---|---|
| Parent Theme | Your main PremiumPress theme (e.g., Directory Theme, Real Estate Theme) |
| Child Theme | Your custom theme that extends the parent theme |
| Template Inheritance | Child theme uses parent theme files unless overridden |
| functions.php | File where you add custom code (both parent and child execute) |
| style.css | Your custom CSS that loads after parent theme styles |
⚠️ Important: PremiumPress themes include all design variations built-in. You only need a child theme if you're making custom code modifications, not for changing designs.
When Do You Need a Child Theme?
Only create a child theme if you're making advanced customizations that require modifying theme files.
Scenarios Requiring a Child Theme
- Custom PHP Functions: Adding custom functions to functions.php
- Template Modifications: Editing core template files (header.php, footer.php, etc.)
- Custom Post Types: Creating completely custom functionality
- Advanced Hooks: Modifying theme behavior with WordPress hooks
- Custom Template Files: Creating entirely new page templates
- Heavy Customization: Significantly altering theme structure
Scenarios NOT Requiring a Child Theme
- CSS Changes: Use Appearance > Customize > Additional CSS
- JavaScript: Use a code snippet plugin or header/footer scripts
- Design Changes: Use built-in Elementor templates
- Color/Font Changes: Use theme customizer
- Page Creation: Use Elementor to build pages
- Content Changes: Edit directly in WordPress
Pro Tip: Try solving your customization need without a child theme first. Most changes can be done through the customizer, Elementor, or plugins.
Benefits of Child Themes
Advantages
- Update-Safe: Parent theme updates won't overwrite your changes
- Organized: Keep customizations separate from core theme
- Reversible: Easy to deactivate and revert to parent theme
- Development-Friendly: Safe environment for testing
- Performance: Only loads modified files, inherits the rest
- Maintainable: Easy to track what you've customized
Disadvantages
- Extra Complexity: More files to manage
- Maintenance: Need to check compatibility after parent updates
- File Duplication: Copying template files can bloat site
- Learning Curve: Requires understanding of theme structure
- Not Always Necessary: Often alternatives are simpler
Creating a Child Theme
Follow these steps to create a child theme for your PremiumPress theme.
Method 1: Manual Creation (Recommended for Learning)
Step 1: Create Child Theme Folder
- Connect to your site via FTP or File Manager
- Navigate to
/wp-content/themes/ - Create a new folder with a descriptive name:
- Format:
parenttheme-child - Example:
premiumpress-directory-child - Use lowercase, hyphens only (no spaces or underscores)
- Format:
Step 2: Create style.css
- Inside your child theme folder, create a file named
style.css - Add this header (replace values with your information):
/*
Theme Name: PremiumPress Directory Child
Theme URI: https://yoursite.com
Description: Child theme for PremiumPress Directory Theme
Author: Your Name
Author URI: https://yoursite.com
Template: premiumpress-directory
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: premiumpress-directory-child
*/
/* Your custom CSS goes here */
⚠️ Critical: The Template: line must exactly match the parent theme folder name.
Step 3: Create functions.php
- In your child theme folder, create
functions.php - Add this code to properly load parent theme styles:
<?php
/**
* Child Theme Functions
*/
// Enqueue parent and child theme styles
function premiumpress_child_enqueue_styles() {
// Load parent theme stylesheet
wp_enqueue_style(
'parent-style',
get_template_directory_uri() . '/style.css'
);
// Load child theme stylesheet
wp_enqueue_style(
'child-style',
get_stylesheet_directory_uri() . '/style.css',
array('parent-style'),
wp_get_theme()->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'premiumpress_child_enqueue_styles' );
// Your custom functions go below this line
Step 4: Add screenshot.png (Optional)
- Create or find an image (1200x900px recommended)
- Name it
screenshot.png - Upload to child theme folder
- This image shows in Appearance > Themes
Step 5: Activate Child Theme
- Go to Appearance > Themes in WordPress
- You should see your child theme listed
- Click Activate
- Your site should look exactly the same
- Now you can add customizations safely
Method 2: Using a Plugin (Easier)
- Install Child Theme Configurator plugin
- Go to Tools > Child Themes
- Click Create New Child Theme
- Select your PremiumPress theme as parent
- Choose analysis mode: New Child Theme
- Configure child theme details:
- Name your child theme
- Add description
- Upload screenshot (optional)
- Click Create New Child Theme
- Plugin creates all necessary files automatically
- Activate the child theme
Method 3: Using WP-CLI (Advanced)
wp scaffold child-theme premiumpress-directory-child --parent_theme=premiumpress-directory --activate
Child Theme File Structure
Understanding the file structure helps you organize your customizations.
Minimal Child Theme Structure
premiumpress-directory-child/
├── style.css (Required - theme header + custom CSS)
├── functions.php (Required - enqueue styles + custom functions)
└── screenshot.png (Optional - theme preview image)
Extended Child Theme Structure
premiumpress-directory-child/
├── style.css
├── functions.php
├── screenshot.png
├── header.php (Override parent header)
├── footer.php (Override parent footer)
├── page.php (Override page template)
├── single.php (Override single post template)
├── archive.php (Override archive template)
├── js/
│ └── custom.js (Custom JavaScript)
├── css/
│ └── custom.css (Additional CSS)
├── images/
│ └── logo.png (Custom images)
└── templates/
└── custom-page.php (Custom page templates)
File Override Priority
WordPress looks for files in this order:
- Child theme - Checks here first
- Parent theme - Falls back if not found in child
Example: If you create header.php in child theme, WordPress uses your version instead of parent's.