wp_enqueue_scripts
调用函数后激发wp_head()
. 所以你的wp_enqueue_script()
打电话太早了。
Register 你的脚本wp_loaded
, enqueue 打开它们wp_enqueue_scripts
.
add_action( \'wp_loaded\', function() {
$base = get_template_directory_uri();
wp_register_script( \'menu\', "$base/js/menu-effect.js" );
wp_register_script( \'thumbnail\', "$base/js/thumbnail-effect.js" );
});
add_action( \'wp_enqueue_scripts\', function() {
wp_enqueue_script( \'menu\' );
wp_enqueue_script(\'thumbnail\');
});