I'm trying to load a js file in WordPress. Note that the js file is in the root directory of the theme, as is functions.php
, here is the code in functions.php
:
function add_theme_scripts() {
wp_enqueue_script( 'script',get_template_directory_uri() . '/script.js', array (), false, true);
}
add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );
This is not working. Am I missing something?
The solution is to call wp_head() in index.php
solved by dreygur
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.