Create a WordPress child theme

Published on July 26, 2019 at 4:17 pm by reMarkable websites

Any changes you make to a WordPress theme will be lost when it is next updated. To avoid this create a child theme.

To create a child theme (within the themes directory) :-

Add a directory with the same name as the theme you would like to modify but with ‘-child’ appended. Change to this directory and use it for the remainder of the article.

Add a style.css file containing the following :-

Theme name: [main theme name] child theme
Template: [main theme directory]

Create a functions.php file containing the following code :-

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
  $parent_style = '[main theme]-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 ),

To override other files you will need to copy them from the main theme’s directory to that of the child theme and edit them there.

Activate your child theme from the admin menu in Appearance > Themes.

Now any styles you add to style.css will override the main theme and you can add new functions in the functions.php file.


Comments are closed here.

Back To Blog