Reputation: 11
how are you I have an issue when I login to the admin panel I face the following errors
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. This notice was triggered by the lity-style handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/customer/www/remny.com/public_html/wp-includes/functions.php on line 5667
Notice: 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. This notice was triggered by the lity-script handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/customer/www/remny.com/public_html/wp-includes/functions.php on line 5667
let me know how can I fix
Upvotes: 0
Views: 4885
Reputation: 2709
In WordPress, you have to enqueue scripts and styles with corresponding function wp_enqueue_script
and wp_enqueue_style
. But, remember these functions should be only called after wp_enqueue_scripts
, admin_enqueue_scripts
, or login_enqueue_scripts
hooks are triggered.
Those hooks are called in different scenarios.
wp_enqueue_scripts
: This hook is triggered for frontend/public side of the WordPress.admin_enqueue_scripts
: This hook is only triggered for the admin side of the WordPress or you can say when the URL contains the wp-admin
.login_enqueue_scripts
: It is a particular hook triggered only on the login page of WordPress which is usually accessed through http://example.com/wp-adminAn example is to enqueue scripts on the public side of the page.
/**
* Enqueue a script with jQuery as a dependency.
*/
function wpdocs_scripts_method() {
wp_enqueue_script( 'custom-script', get_stylesheet_directory_uri() . '/js/custom_script.js', array( 'jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'wpdocs_scripts_method' );
As you can see, the function wp_enqueue_script
in only called after the wp_enqueue_scripts
hook is triggered.
Reference:
Upvotes: 1