I have tried to include my javascript file in the following way:
function theme_scripts()
{
wp_enqueue_scripts( 'custom-script', get_template_directory_uri() . '/js/menu-fix.js',array('jQuery'), true);
}
add_action('init', 'theme_scripts');
This file is included in functions.php
But for some reason the script does not get included.
I have got wp_head()
in header.php
and wp_footer()
in footer.php.
Edit
So I changed my script to:
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');
But still it isn't loaded.
This is how my footer.php
looks like:
<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();?>
wp_enqueue_scripts
hook instead ofinit
. See the Codex and this answer for details. Also, yourwp_enqueue_scripts()
call is missing either the$version
parameter, or has$version
set totrue
and does not set the$in_footer
parameter.