So i got a parenttheme that enques scripts like this:
function my_scripts() {
wp_deregister_script('jquery');
wp_enqueue_script( 'modernizr', get_stylesheet_directory_uri().'/assets/js/dist/modernizr.min.js', array(), '1.0', false );
wp_enqueue_script( 'jquery', get_stylesheet_directory_uri().'/assets/js/dist/jquery.min.js', array(), '1.0', false );
wp_register_script( 'scripts', get_stylesheet_directory_uri().'/assets/js/dist/scripts.min.js', array(), '1.0', true );
wp_enqueue_style( 'fonts', 'https://fonts.googleapis.com/css?family=Lora:400,400italic', array(), '1', 'screen,projection' );
wp_enqueue_style( 'style', get_stylesheet_directory_uri().'/style.css', array(), '1', 'screen,projection' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts' );
I shuld add that I am using gulp to minify the above scripts and put them in the dist
-folder.
Everything works fine in the parent-theme but I have now created a child-theme and the the scripts are not found.
The console logs:
http://localhost:3000/PARENT/wp-content/themes/CHILD/assets/js/dist/jquery.min.js?ver=1.0 - 404
All I have in my child-theme is 2 files:
style.css: /*
Theme Name: child
Description: parent child theme
Template: parent
Version: 1.0.0
*/
and functions.php:
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>
I do not know what causes the error but some thoughts i have had are:
Since im using gulp to minify the scripts, maybe they are not yet created when the child-theme searches for them.
As mentioned above the code looks for the files in: the child-theme:
ttp://localhost:3000/PARENT/wp-content/themes/CHILD/assets/js/dist/jquery.min.js?ver=1.0 -
Maybe it should look for the files in the parent?
Help appreciated. Thank you.