Web Development 3 min read

How to Create a WordPress Child Theme

Editing a theme directly means losing your changes on the next update. A child theme keeps your customisations safe. Here's how to create one in a few minutes — and when you don't need one.

On this page

Key takeaways

  • A child theme inherits everything from a parent theme and lets you override styles, templates and functions safely.
  • Your changes survive parent theme updates.
  • You need just two files to start: style.css and functions.php.

Editing your theme’s files directly feels quick — until the next theme update wipes out every change. A child theme solves that. It’s the standard way to customise classic WordPress themes beyond what the Customizer allows.

When you need a child theme#

Change Child theme needed?
Colours, fonts, logo via theme settings No
A few CSS tweaks No — Additional CSS is fine
Modifying template files (header, single post) Yes
Adding PHP functions, hooks, custom post types Yes (or a site-specific plugin)
Large custom stylesheet Yes

Create a child theme in 5 minutes#

  1. In wp-content/themes/, create a folder, e.g. generatepress-child.
  2. Create style.css:
    /*
    Theme Name: GeneratePress Child
    Template: generatepress
    Version: 1.0.0
    */

    Template must match the parent theme’s folder name exactly.

  3. Create functions.php to load the stylesheets:
    <?php
    add_action( 'wp_enqueue_scripts', function () {
      wp_enqueue_style( 'child-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) );
    }, 20 );

    Many modern parent themes load their own CSS automatically; check whether you also need to enqueue the parent stylesheet.

  4. Zip the folder and upload via Appearance → Themes → Add New, or upload by SFTP.
  5. Activate the child theme. Re-check menus and widgets — and Customizer settings, which are stored per theme (most themes offer an import/export option).

Need a hand with this?

Get a quick, honest review of your website’s SEO.

Chat on WhatsApp

Overriding templates#

Copy a template file from the parent (e.g. single.php or template-parts/content.php) into the same path in your child theme and edit it there. WordPress uses the child version automatically. Keep overrides minimal — the more you copy, the more you have to update when the parent changes.

Using hooks instead of copying files#

// Add a call-to-action after every post
add_filter( 'the_content', function ( $content ) {
  if ( is_singular( 'post' ) ) {
    $content .= '<p class="cta">Need help? <a href="/contact/">Get in touch</a>.</p>';
  }
  return $content;
} );

Hooks (actions and filters) are more update-proof than template copies.

Block themes#

For block themes, much customisation happens in the Site Editor and theme.json. Child themes still work: add your own theme.json to override settings and a templates/ folder for template changes.

Child theme FAQ#

Does a child theme slow down my site?#

No meaningful impact — it’s one extra small stylesheet at most.

Should a custom-built theme have a child theme?#

If the theme was built specifically for you and won’t receive third-party updates, you can edit it directly with version control.

What about code snippets plugins?#

For small PHP snippets independent of the theme, a snippets plugin or site-specific plugin is a good alternative.

Found this useful? Share it

Join the discussion

Your email address will not be published. Required fields are marked *

Security code image. If you cannot read it, press refresh or contact me on WhatsApp.