Post at a Glance

Post at a Glance
Step by step directions for creating your first WordPress child theme. Never lose code updates again when you update template files.

If youโ€™re like me you like to update and tweak your WordPress template with great frequency. By creating a WordPress Child Theme youโ€™ll never lose these updates again.

While itโ€™s great to be able to update your theme to add functionality and additional theming it becomes taxing if you update your template. Updating your template is important to do as new security features, bug fixes and usability updates become available. It makes sense to keep your files current, but then what happens to all those in-line code tweaks youโ€™ve added?

The solution to this is to create a WordPress child theme. A WordPress child theme allows you to continue to update your theme files while not over writing your code updates. Creating a WordPress child theme is pretty easy to do and will save you countless hours of re-coding every time thereโ€™s a new update for your theme file.

How to set up a WordPress Child Theme

To create your first WordPress child theme youโ€™ll need to create a folder with the same name of the โ€œParentโ€ theme you want the child to append. In this example Iโ€™ll create a folder called โ€œtwentytwentyfive-childโ€œ. Youโ€™ll need to start by creating 2 files styles.css and functions.php.

This is assuming your using a style-sheet called style.css. If yours is called something different youโ€™ll have to rename it appropriately. The following paragraph outlines the new code youโ€™ll need to add to your CSS in order to define and call your new child-theme.

Step 1 Create your WordPress Child Theme folder

Like I stated above create a theme folder with the following naming convention โ€œtwentytwentyfive-childโ€œ. This is the folder where you will upload style.css, functions.php and any other file you wish to alter that lives in your parent theme. This file should be added to the same folder as the parent theme.

WordPress Child Theme CSS Anatomy Explained

Itโ€™s brilliantly simple to create your own WordPress child theme and really takes very little time depending on how many files you wish to update. Youโ€™ll have to add this first bit of code to get started. Iโ€™ll outline what it is your changing and what lines of code you need to update to reflect your own theme. In this example Iโ€™ll be using the default WordPress 2025 theme.

An explanation of what youโ€™re defining follows.

<strong>Theme Name:</strong> Twenty Twentyfive 
<strong>Theme URI:</strong> https://wordpress.org/themes/twentytwnetyfive-child/ 
<strong>Description:</strong> Twenty Twentyfive Child Theme 
<strong>Author:</strong> Your Name 
<strong>Author URI:</strong>
<strong>Template:</strong> twentytwentyfive 
<strong>Version:</strong> 1.0.0 
<strong>License:</strong> GNU General Public License v2 or later 
<strong>License URI:</strong> http://www.gnu.org/licenses/gpl-2.0.html 
<strong>Tags:</strong> add optional description tags 
<strong>Text Domain:</strong> twentytwentyfive-child

Step 2 create your style.css

Add the code above to the beginning of our styles.css. Additional styles can be added to this style-sheet after the code below.

See also  Parallax CSS for Mobile: Stunning Design Principles, Performance & Practical Implementation

Theme Name: Twenty Twentyfive
1. This is the title that will show up in your theme description.

Theme URI: https://wordpress.org/themes/twentytwentyfive-child/
Link to your themeโ€™s page.

Description: Twenty Twentyfive Child Theme
2. How your description will read.

Author: Your Name
3. This can be your own name or the name of your design/ development team.

Author URI:
4. This can be a link to your homepage or one that links to more information about your theme if you plan to distribute it.

Template: twentytwentyfive
This piece is important. This should be the exact name of the file your theme lives in your content folder. Itโ€™s what is used to reference your child theme so keep it case sensitive.

Version: 1.0.0
5. Theme version shows up in the description.

License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Licensing information optional.

Tags: add optional description tags
6. Itโ€™s a good idea to add tags if you plan on distributing your theme otherwise this isnโ€™t necessary to create a child theme.

Text Domain: twentytwentyfive-child
Defines the name of the child theme

Step 3 create your WordPress Child Theme functions.php file

The next step is to create your funtions.php file. This file calls your child-theme and loads it along with the rest of your page to call your new updates.

Make sure you add โ€œ-styleโ€ to the end of line 3 below. It should read as follows:

$parent_style = โ€˜twentytwentyfive-styleโ€™;

<?php
function my_theme_enqueue_styles() {
$parent_style = 'twentytwentyfive-style'; /
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>

Step 4 Activate your child theme

Once youโ€™ve created style.css & functions.php and uploaded them to the child theme folder you created earlier youโ€™ll need to activate your new child theme.

Go to Appearance > Themes and you will see your new child theme awaiting activation. Click to activate it and your ready to start utilizing the benefits. To add bigger code changes effecting pieces of your site follow directions in the last step below.

Step 5 Add Updated files to your WordPress child theme folder

Considering you want to do more than just style your theme you probably want to add existing functionality to your posts or pages. For example I added updates to my single.php file to add banners and functionality to my post pages.

See also  Fluent Forms for WordPress: The Ultimate Tool for Effortless Form Creation

All you need to do is download the file you donโ€™t want to change when you update your theme. In our example Iโ€™ll be pulling footer.php from the twentytwentyfive parent folder. Once youโ€™ve added your new code to this file youโ€™ll want to upload it to the child theme folder. To make changes to different parts of your site simply download and alter files from your parent folder and upload them to the child theme folder.

From here on out you can freely update your template files any time thereโ€™s a new update while not effecting code changes that live in your child folder. Hope this post helps shed some light.

Happy blogging pixel pushers.


Request Web Design or SEO Services

Related Posts:


Nate Balcom Avatar

Nate Balcom

Web Designer | UX | SEO | AEO

I build prototypes, write front end code & SEO/AEO websites. UX designer & creator of scalable, accessible responsive web experiences.

Areas of Expertise: Web Design/ Development, HTML5, CSS3, JS, jQuery, PHP, SEO, AEO, CMS, UX Design, Graphic Design, Prototyping, Figma, Wire-framing, E-commerce, Mobile Applications, Google Analytics, Blogging, Video Editing, UI Design, SEM, Screaming Frog, Confluence, Google PSI, Google Lighthouse, Adobe Creative Suite
Web Design ServicesWeb Design Services: Custom, responsive sites with stunning UX/UI, fast load times & SEO-ready code. Convert visitors into customers.More >>
SEO ServicesSearch Engine Optimization Services: Boost your site's visibility with tailored keyword research, on-page optimization & analytics. Drive organic traffic!More >>
WordPress ServicesWordPress Services: Custom themes, WooCommerce, speed & SEO optimization. Secure, scalable sites that rank higher & convert better.More >>