好的,我正在尝试消除所有可能的变量以进行故障排除。 所以我没有在我的functions.php中删除这个代码,而是将我的代码放在我的header.php文件中: p>
<?php $ mdgtemplateloc = get_bloginfo('template_url')。 '/ JS /'; ?>
<?php echo'<! - '。 $ mdgtemplateloc。 ' - > ?>
<?php wp_enqueue_script('hoverIntent',$ mdgtemplateloc.'hoverIntent.js',array('jquery')); ?>
<?php wp_enqueue_script('mdMenuAnimation',$ mdgtemplateloc.'mdMenuAnimation.js',array('hoverIntent')); ?>
code> pre>
结果是在源中插入了一些空格,注释按请求显示。 我的理解是这会插入像 p>
< script type =“text / javascript”src =“[url] /js/mdMenuAnimation.js”>< / script>
code> pre>
我想以正确的方式做到这一点,但是wp_enqueue_script一直在给我什么。 我怀疑我做的事情从根本上是错误的,但我找不到它,我通过google或stackoverflow找不到任何东西,或者wp codex都没有帮助。 p>
澄清一下,这是什么 我之前在functions.php文件中: p>
function mdg_setup_scripts(){
$ mdgtemplateloc = get_bloginfo('template_url')。'/ js /';
wp_register_script('hoverIntent',get_bloginfo('template_url')。'/ js / hoverIntent.js',array('jquery'));
wp_enqueue_script('hoverIntent');
wp_register_script('mdMenuAnimation',$ mdgtemplateloc。 'mdMenuAnimation.js',array('hoverIntent'));
wp_enqueue_script('mdMenuAnimation');
}
add_action('wp_enqueue_scripts','mdg_setup_scripts');
code> pre>
这也没有产生任何曾经调用过脚本的输出。 我知道这第二个更像是应该是什么,但它没有做任何事情。 p>
div>