3

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.

5
  • I bet it has something to do with the error at the top of the page: 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 Of course, turning the maint. mode plugin off might help as well...:)
    – jfacemyer
    Feb 28, 2013 at 4:46
  • @jfacemyer Yeah, I just noticed that error as well. Maint Mode is now off(thought, I did that before, sorry). I turned off all plugins causing trouble, and am left with the error you mentioned. Problem is, I can't find that line of code anywhere, much less in the specified file on the specified line. Feb 28, 2013 at 4:58
  • grep your theme and plugin directories for wp_enqueue_script. It can't be that hard to find.
    – s_ha_dum
    Feb 28, 2013 at 5:22
  • @s_ha_dum as mentioned below, scanned a few files and did a specific search for wp_enqueue_style and enqueue, nothing found. Feb 28, 2013 at 5:32
  • 1
    Don't "scan a few files". Search the whole wp-content directory. Given that the error references wp_enqueue_style, it has to be there. The problem is not in /wp-includes/functions.php. Sometimes the error messages mislead.
    – s_ha_dum
    Feb 28, 2013 at 5:37

1 Answer 1

9

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' );
6
  • I understand the concept, and I appreciate your time and answer. My problem is, I can't find wp_enqueue_style in any of my wp-includes files. Feb 28, 2013 at 5:22
  • You should check it in your theme folder. It is the notice that is being triggered from /wp-includes/functions.php. This folder contains core WordPress files.
    – RRikesh
    Feb 28, 2013 at 5:24
  • Checked that file, did a specific search for wp_enqueue_style and enqueue, nothing found. Feb 28, 2013 at 5:31
  • which file you checked? Check the folder of you current theme - wp-content/themes/your-theme
    – RRikesh
    Feb 28, 2013 at 6:21
  • I've checked EVERY file in my current theme folder, EVERY file in wp-includes(found wp_enqueue_style in class-wp-admin-bar.php, class-wp-customize-control.php, class-wp-editor.php, functions.wp-styles.php, general-template.php, and media.php BUT nothing looked out of the ordinary, and I don't know how to proceed further with checking. I appreciate your efforts with this. Feb 28, 2013 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.