• Hello,

    I created a child theme to Twenty twenty-one. I created style.css and functions.php. It worked. I then tested with commenting these lines out in functions.php:

    // enqueue parent styles
    
    //function ns_enqueue_styles() {
    //    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    //}
    
    //add_action( 'wp_enqueue_scripts', 'ns_enqueue_styles' );

    It still works.

    Why does all tutorials say that you must enqueue parent and child theme in functions.php? Is that no longer necessary in the latest WordPress 5.8?

    Fred

    • This topic was modified 4 years, 9 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 1 replies (of 1 total)
  • Moderator t-p

    (@t-p)

    There are three core principles to parent/child theme logic in WordPress:
    1. functions.php files from both parent and child get executed during load, with one of child them first (this is little counter-intuitive so worth remembering).

    2. “Template directory” refers to parent theme and “stylesheet directory” refers to child theme. If no child theme is being used they are same and both refer to single current theme.

    3. Each template file is first looked for in child theme, then in parent theme.

    Be aware that your customization will be over-written the next time you upgrade your parent theme. For this reason, it is recommended creating a Child Theme.

Viewing 1 replies (of 1 total)

The topic ‘Child theme without functions.php’ is closed to new replies.