Your Changes Disappear After an Update? Discover the Secret of WordPress Child Themes
There’s a moment of dread that nearly every WordPress site owner knows. You see a notification for an available theme update. You know you should install it for security reasons, but you feel a cold sweat. You click “Update,” and a moment later, all your carefully implemented changes to the design and functionality… are gone. Irretrievably.
This is a trap many people fall into. In a previous project, to fix a confusing navigation issue, I added a custom code snippet to my client’s theme files. The fix worked perfectly, but I knew that leaving it there was like building a sandcastle—beautiful, but gone with the first tide. That “tide” would be the very next update.
My job was not only to fix the problem but to do it professionally, in a way that would secure the work for the future.
The Problem: Why Do Changes Disappear in the First Place?
Imagine your theme is a house from a catalog. An update isn’t like repainting the walls. It’s like demolishing the old house and building a new, improved version from the same series in its place. All your custom modifications—repainted walls or extra outlets—are leveled to the ground. That’s why you should never, ever directly modify the original theme’s files.
The Solution: Building a Safe "Home Extension" (A Child Theme)
The gold standard in the WordPress world is creating a Child Theme. Using our metaphor, it’s like a home extension built onto the existing house. We place all our modifications, additional features, and styles in this safe, separate space. When the “main building” undergoes a major renovation (an update), our extension remains untouched and still fits perfectly. It’s simple, elegant, and incredibly effective.
A Practical Workshop: How to Create a Child Theme in 4 Steps
Creating a child theme is easier than you think. Here’s a step-by-step guide on how to do it for the popular Astra theme (the process for other themes is analogous):
Step 1: Create the Child Theme Folder
Connect to your server via FTP (e.g., with FileZilla) and navigate to the wp-content/themes/ directory. Create a new folder there and name it astra-child.
Step 2: Create the style.css File – The Heart of the “Extension”
Inside the astra-child folder, create a file named style.css and paste the following header into it. The most important line is Template: astra—it must exactly match the name of the parent theme’s folder.
/*
Theme Name: Astra Child
Theme URI: https://wpastra.com/
Description: Astra Child Theme
Author: Your Name
Template: astra
Version: 1.0.0
*/
Step 3: Create the functions.php File and Link the Themes
In the same folder, create a file named functions.php and paste the code below into it. This code’s job is to load the original styles from the Astra theme so that your site looks correct.
< ?php
// Enqueue the parent theme's (Astra) stylesheet
function astra_child_enqueue_parent_styles() {
wp_enqueue_style( 'astra-parent-style', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'astra_child_enqueue_parent_styles' );
/*
* ===============================================
* YOUR OWN CUSTOMIZATIONS
* ===============================================
* From this point on, you can safely add your own PHP code.
*/
Step 4: Activate and Enjoy the Peace of Mind
That’s it! Go to your WordPress dashboard (Appearance -> Themes), and you will see your newly created “Astra Child” theme. Activate it. From now on, you can add all your custom PHP code snippets to the functions.php file in the astra-child folder, and your CSS changes to style.css in the same place. They will be safe forever.
Thanks to this simple procedure, the client can now click “Update” without fear, knowing that her key functionalities are secure. It’s an investment in stability and peace of mind.
True professionalism isn’t just about solving a problem, but about anticipating and preventing future ones. It’s about thinking ahead and providing solutions that work not only today but a year from now.
Are you afraid to click the “Update” button in your WordPress? Or do you want to make code changes but don’t know how to do it safely?
Contact me. We will implement a professional and secure solution that will stand the test of time.
