I'm creating a WordPress theme, but wp_enqueue_scripts
does not work. The code that is in functions.php
is:
<?php
function scripts_and_styles() {
if ( ! is_admin() ) {
wp_enqueue_script( 'jquery' );
wp_register_style( 'style.css',get_template_directory_uri().'/style.css' );
wp_enqueue_style( 'style.css' );
wp_register_style( 'bootstrap.min.css','https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' );
wp_enqueue_style( 'bootstrap.min.css' );
}
}
add_action('wp_enqueue_scripts', 'scripts_and_styles');
?>
Other information that may help you identify what is happening:
- When I enter
echo 'Oi!';
appears Hi! inindex.php
, as expected; - I have to insert in
header.php
o<?php do_action('wp_enqueue_scripts') ?>
, and from what I understood this would not be necessary; - When I use
var_dump
onwp_enqueue_script( 'jQuery' );
and onwp_enqueue_script()
it is 'printed'NULL
onindex.php
; - Nothing that uses
jQuery
works on my theme (I guess because I can not call it); - I use
XAMPP
.
Just to make it clear: It's not just jQuery that does not work, nothing is included. It does not call neither style nor script. I am aware that jQuery comes included in Wordpress and that I have to point out if any script depends on it.