There are two useful action hooks for registering / enqueuing external scripts & styles in WordPress:
1. wp_enqueue_scripts
:
wp_enqueue_scripts
is the proper action hook to use when enqueuing scripts & styles for the front end.
So if you want to add the CSS file on the frontend of the site, then your CODE will be like:
function my_theme_sty() {
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.css' );
}
add_action( 'wp_enqueue_scripts', 'my_theme_sty' );
2. admin_enqueue_scripts
:
On the other hand, admin_enqueue_scripts
is the proper action hook to use when enqueuing scripts & styles for the admin panel.
So if you want to add the CSS file on the admin panel of the site, then your CODE will be like:
function my_theme_sty() {
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.css' );
}
add_action( 'admin_enqueue_scripts', 'my_theme_sty' );
admin_enqueue_s
hook in WordPress.