Tutorials

Creating a Custom Child Theme for Sports Bench

Level: Intermediate

When customizing a theme, the best practice is to create a child theme. This way, when you update the parent theme, all of your changes will still remain intact. Creating a child theme is very simple if you use the steps below.

  1. Using your preferred FTP client, navigate to the “themes” directory inside the “wp-content” directory and create a directory titled “sports-bench-child”.
  2. Once there, create a style.css file and add the following lines of code in there and save.
    /*
    Theme Name: Sports Bench Main Theme Child
    Description: Child theme for Sports Bench Main Theme
    Author: <your name>
    Template: sports-bench
    */
  3. Then create a functions.php file and add the following code and save.
    <?php
    function sports_bench_child_theme_styles() {
        wp_enqueue_style( 'main_css', get_stylesheet_uri() );
    }
    add_action( 'wp_enqueue_scripts', sports_bench_child_theme_styles, 10 );
    ?>

Congratulations! You’ve now set up your child theme. You can now add in your custom CSS and edit any of the template files from the Sports Bench Main Theme and keep them safe during a theme update.

Continue Learning

Getting Started with the Sports Bench Main Theme