D
D
DimDim77782019-10-11 20:42:07
WordPress
DimDim7778, 2019-10-11 20:42:07

What is this error on Wordpress + Woocommerce site and how to fix it?

Hello.
Added new functionality to the site through the theme file functions.php
Decided to check it out. Turned it on and got this notification:
define('WP_DEBUG', true);

Notice: wp_enqueue_style 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. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /public_html/wp-includes/functions.php on line 4773 Notice: wp_enqueue_style 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. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /public_html/wp-includes/functions.php on line 4773

I found the same question on the net, but so far it has not been answered:
https://stackoverflow.com/questions/56471327/home-...
Tell me what it could be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yanchevsky, 2019-10-11
@deniscopro

Hello.
Place the call to the wp_enqueue_style function in the wp_enqueue_scripts hook .
Example:

add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
function theme_name_scripts() {
  wp_enqueue_style( 'style-name', get_stylesheet_uri() );
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question