1
votes

So I have this Child Theme and when I try to enqueue the styles and the javascript I run into an error:

  • wp_enqueue_script is working fine
  • wp_enqueue_style doesn't work at all

wp_head() is included in the header and it worked before, but after updating Avast theme and wordpress the problem started to occurre.

functions.php

function theme_enqueue_styles() {

    wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css'); //not working
    wp_enqueue_style( 'fancy', get_stylesheet_directory_uri() . '/css/jquery.fancybox.min.css'); //not working
    wp_enqueue_script( 'devtools', get_stylesheet_directory_uri() . '/js/main.min.js' ); //working

}

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
1

1 Answers

2
votes

Check out the wordpress child themes documentation.

There you can find this line

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
    wp_enqueue_style( 'child-style', get_stylesheet_uri(),
        array( 'parenthandle' ), 
        wp_get_theme()->get('Version') // this only works if you have Version in the style header
    );
}