This is the correct way to enqueue scripts.
/**
* Proper way to enqueue scripts and styles.
*/
function themeslug_enqueue_style() {
wp_enqueue_style( 'my-theme', 'style.css', false );
}
function themeslug_enqueue_script() {
wp_enqueue_script( 'my-js', 'filename.js', false );
}
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_style' );
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_script' );
Having multiple actions on the wp_enqueue_scripts hook is perfectly fine.
( https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/ )
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…