Twenty Twenty-one child theme

If you want to customise your WordPress theme, you can’t avoid making a child theme unless you use a plugin.

If you want to use a plugin, there are many plugins out there to customise WordPress themes. As for the Twenty Twenty-one theme, I recommended this and this plugins.

I prefer making a child theme, however.

Here how you can make your child theme for Twenty Twenty-one WordPress theme.

  • Create a child theme folder under ‘wp-content/themes/’ and name it ‘twentytwentyone-child’.
  • Create a PHP file and name it ‘functions.php’ and place it in the child theme folder. The PHP file should contain the following code:
//CORE FUNCTION FOR CHILD THEME
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
    $parenthandle = 'twenty-twenty-one-style'; // This is 'twenty-twenty-one-style' for the Twenty Twenty-one theme.
    $theme = wp_get_theme();
    wp_enqueue_style( $parenthandle, get_template_directory_uri() . '/style.css', 
        array(),  // if the parent theme code has a dependency, copy it to here
        $theme->parent()->get('Version')
    );
    wp_enqueue_style( 'custom-style', get_stylesheet_uri(),
        array( $parenthandle ),
        $theme->get('Version') // this only works if you have Version in the style header
    );
}
  • Create a CSS file and name it ‘style.css’ and place it in the child theme folder. The CSS file should contain the following code*:
/*
 Theme Name:   Twenty Twenty-One Child
 Theme URI:    https://aung.com.au/
 Description:  A child theme of Twenty Twenty-One WordPress theme.
 Author:       SoftCode Web Solutions
 Author URI:   https://softcode.com.au
 Template:     twentytwentyone
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
*/
@import url("../twentytwentyone/style.css");

*Your own Theme URI and Author information should be used.

  • Create a PNG file and name it ‘screenshot.png’ and place it in the child theme folder. Your PNG file can be any photo or image, and the recommended size is 1200 x 900 pixels.

That’s all set!

Last updated on May 23rd, 2021
Share this:

Leave a comment

Your email address will not be published. Non-standard characters in the comment form are not permitted and will be removed. Required fields are marked *