Developer Snippet Diary

How to create Child theme

why child theme is needed?
A child theme is like a protective layer built on top of your main (parent) theme.
It inherits everything from the parent layout, styles, functions  but lets you safely customize parts of it.

If you edit files directly in your parent theme (like style.css, header.php, or functions.php), everything works fine until the theme updates.

on update: ???? All your customizations are lost, because the update replaces the old theme files.

Child theme
1. Safe Updates    your custom CSS, PHP, and templates stay intact.
2. Clean Separation    All your modifications live in the child theme, making it easier to debug, backup, or migrate.
3. Easy Customization    You can override only the files you need — e.g., just header.php or single.php.
4. Reuse or Revert Anytime    If something breaks, just switch back to the parent theme.
5. Extend Without Mess    Add new PHP functions, scripts, and styles without touching the parent.

 

1. Locate Your Current Theme /wp-content/themes/ ie its astra

2. Create a New Folder for the Child Theme 

/wp-content/themes/astra-child/

3. Add style.css

/*
Theme Name: Astra Child
Theme URI: https://example.com
Description: Child theme for Astra
Author: Your Name
Template: astra
Version: 1.0.0
*/

Paste screenshot.jpg inside /wp-content/themes/astra-child/ to give it thumbnail

Navigate to Appearance → Themes. and activate child theme

Posted by: R GONDAL
Email: rizikmw@gmail.com