我尝试通过以下方式包含javascript文件:
function theme_scripts()
{
wp_enqueue_scripts( \'custom-script\', get_template_directory_uri() . \'/js/menu-fix.js\',array(\'jQuery\'), true);
}
add_action(\'init\', \'theme_scripts\');
此文件包含在functions.php
但由于某些原因,脚本没有包含在内。
我有wp_head()
在里面header.php
和wp_footer()
在页脚中。php。
编辑,因此我将脚本更改为:
function theme_scripts()
{
wp_enqueue_scripts( \'custom-script\', get_template_directory_uri() . \'/js/menu-fix.js\',array(\'jquery\'), \'1.0\',true);
}
add_action(\'wp_enqueue_scripts\', \'theme_scripts\');
但它仍然没有加载。这就是我footer.php
看起来像:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="<?php bloginfo(\'template_url\'); ?>/js/bootstrap.min.js"></script>
<?php wp_footer();?>