Debugging an error: wp_enqueue_style was called incorrectly

I’ve just uploaded a new, custom theme to find that the container is a fraction of the intended width, and the sections below the home section(this is one single page, long site utilizing ids/anchors to navigate) are no longer showing.
I turned on DEBUG to see if I could spot the problem, and after deactivating problematic plugins, I’m left with this error:

Notice: wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /home/achenn/public_html/frshstudio.com/wp-includes/functions.php on line 2959

Problem is, the only thing on that particular line is:

trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );

I’ve seen other blog posts and forums, but the line they are telling me to search for is non-existent in this file, much less on the given line.

Any tips, ideas, etc on how to remedy this challenge are greatly appreciated.

phrase in question is not in file

Live site.

1 Answer
1

In other words, you should not perform a wp_enqueue_style which is not hooked to wp_enqueue_scripts.

Your wp_enqueue_style should be in a function, and you should hook that function to wp_enqueue_scripts like in the following example:

function wpse88755_enqueue(){
  # call  wp_enqueue_style here
}

#hook the function to wp_enqueue_scripts
add_action( 'wp_enqueue_scripts', 'wpse88755_enqueue' );

Leave a Comment