wp_enqueue_script was called incorrectly. Scripts and styles


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 do:

    function ppibfi_enqueue_scripts() {
   wp_enqueue_script( 'jquery' );
   wp_enqueue_script( 'thickbox' );
   wp_enqueue_script( 'media-upload' );
function ppibfi_enqueue_styles(){
    wp_enqueue_style( 'thickbox' );
add_action( 'wp_enqueue_scripts', 'ppibfi_enqueue_scripts' );
add_action( 'wp_enqueue_scripts', 'ppibfi_enqueue_styles' );

But the code in my website does not start with the same like a function it just states:

//load scripts
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'), '');


// fix google map in the header issue
function googlemaphome() {
    if ( is_front_page()  ) {
       wp_register_script ('googlemaps', 'http://maps.google.com/maps/api/js?&sensor=false', false, '3');
add_action('wp_enqueue_scripts', 'googlemaphome');


add_action( 'wp_enqueue_scripts', 'jt_style_changer' );

 //load the responsive style
 function responsive_styles()
{ wp_enqueue_style('responsive', get_stylesheet_directory_uri() . '/styles/responsive.css',false,'1.0','all');}

Does anybody know how to rewrite so there is no error? Any help would be appreciated as I am not a developer.

Ilamos 6 months 2021-05-22T00:33:26-05:00 0 Answers 0 views 0

Leave an answer