wp_enqueue_script was called incorrectly

Viewed 61

I am not a developer, but I have a theme that is giving me the error wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks.

I have read some solutions where they suggest to change to:

function wpb_adding_scripts() {
wp_register_script('my_amazing_script', plugins_url('amazing_script.js', __FILE__), array('jquery'),'1.1', true);
wp_enqueue_script('my_amazing_script');
}

add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts' );  
?>

I have these scripts in functions.php:

wp_enqueue_script('smoothscroll', get_bloginfo('stylesheet_directory').'/includes/js/smoothscroll.js', array('jquery'), '');
//wp_enqueue_script('carrosel', get_bloginfo('stylesheet_directory').'/js/infinite-carousel.js', array('jquery'), '');
wp_enqueue_script('marker', get_bloginfo('stylesheet_directory').'/includes/map/js/marker.js', array('jquery'), '');
//wp_enqueue_script('carrouse', get_bloginfo('stylesheet_directory').'/includes/js/carrousel.js', array('jquery'), '');
wp_enqueue_script('tinycar', get_bloginfo('stylesheet_directory').'/js/jquery.tinycarousel.min.js', array('jquery'), '');


add_action( 'wp_enqueue_scripts', 'jt_style_changer' );

add_action('wp_enqueue_scripts', 'googlemaphome');

I am not sure how rewrite it correctly so it will not show an error, can you please suggest a solution?

0 Answers
Related