I have this code below and it seems not working:
function load_custom_wp_admin_style() {
wp_register_style( 'custom_wp_admin_css', get_stylesheet_directory_uri() . '/admin-style.css', false, '1.0.0' );
wp_enqueue_style( 'custom_wp_admin_css' );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );
But when I replace it with wp_enqueue_scripts instead of admin_enqueue_scripts then it will load the file. I'm not sure what's the issue.
admin_enqueue_scripts() only fires in your back-end admin area (/wp-admin/) - https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
wp_enqueue_scripts() is used to properly enqueue scripts in front-end (https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts)
So if your want load stuff in front-end wp_enqueue_scripts() is the way to go.
Cheers
add_action( 'admin_enqueue_scripts', 'your_function_name' ); this is use for the backend side work.
add_action( 'wp_enqueue_scripts', 'your_function_name' ); this is use for front-end side work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With