WordPress makes use of a system of so-called “hooks”, that are capabilities which are run at particular factors inside the strategy of constructing the webpage for the browser.
The system runs like this:
- A mode is meant to be inside the
<head>
portion of an HTML doc. - inside the operate that outputs the
<head>
portion, WordPress executes a operate namedwp_enqueue_scripts
. (that is for the “frontend” portion of the web site. On the “backend” portion, a operate namedadmin_enqueue_scripts
is executed, and on the login web page, the operate is known aslogin_enqueue_scripts
)
Inside your personal code, you’ll be able to “inject” your personal stylesheets into this operate like this:
add_action( 'wp_enqueue_scripts', 'my_awesome_additional_styles' );
//the earlier line primarily says "Hey WordPress, if you output all of your scripts and kinds,
//please do no matter is written within the operate my_awesome_additional_styles
operate my_awesome_additional_styles(){
$css_path = plugins_url( "css/fashion.css", __FILE__ );
$css_dir = plugin_dir_path( __FILE__ ) . "css/fashion.css";
if( file_exists( $css_dir ) ) {
wp_enqueue_style( 'acf-block-css' , $css_path, array(), filemtime( $css_dir ) );
//The earlier line primarily says: "Hey WordPress, output the hyperlink to this stylesheet, okay?"
}
}
You could find extra data right here and right here.
Glad Coding!