## advanced custom fields – Function wp_enqueue_style was called incorrectly

Question

WordPress uses a system of so-called “hooks”, which are functions that are run at specific points within the process of building the webpage for the browser.

The system runs like this:

• A style is supposed to be within the <head> portion of an HTML document.
• within the function that outputs the <head> portion, WordPress executes a function named wp_enqueue_scripts. (this is for the “frontend” portion of the website. On the “backend” portion, a function named admin_enqueue_scripts is executed, and on the login page, the function is named login_enqueue_scripts)

Within your own code, you can “inject” your own stylesheets into this function like this:

add_action( 'wp_enqueue_scripts', 'my_awesome_additional_styles' );
//the previous line essentially says "Hey WordPress, when you output all your scripts and styles,
$css_path = plugins_url( "css/style.css", __FILE__ );$css_dir    = plugin_dir_path( __FILE__ ) . "css/style.css";
if( file_exists( $css_dir ) ) { wp_enqueue_style( 'acf-block-css' ,$css_path, array(), filemtime( \$css_dir ) );