Enqueue Stylesheets Error Log Messages

Home Forums Using Thematic Child Themes Build Your Own Custom Child Themes Enqueue Stylesheets Error Log Messages

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  samdobrow 1 year, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #4461

    samdobrow
    Participant

    I have a child theme based on v 1.0.4 which was built quite a while ago. I added a standard function to the function.php file to enqueue the numerous style sheets as follows:

    <?php
    
    //  Thematic ver 1.0 requires use of wp_enqueue_style function to load multiple stylesheets
    //   this replaces the @import function in style.css
    
    function childtheme_create_stylesheet() {
    	
     wp_enqueue_style( 'reset_style', get_template_directory_uri() . '/library/styles/reset.css' );
     wp_enqueue_style( 'typography_style', get_template_directory_uri() . '/library/styles/typography.css' );
     wp_enqueue_style( '2c-r-fixed_style', get_template_directory_uri() . '/library/layouts/2c-r-fixed.css' );
     wp_enqueue_style( 'images_style', get_template_directory_uri() . '/library/styles/images.css' );
     wp_enqueue_style( 'default_style', get_template_directory_uri() . '/library/styles/default.css' );
     wp_enqueue_style( 'plugins_style', get_template_directory_uri() . '/library/styles/plugins.css' );
     wp_enqueue_style( 'stylesheet_style', get_stylesheet_directory_uri() . '/styles//style.css' );
     
    }
    
    add_action('wp_enqueue_scripts','childtheme_create_stylesheet');
    
    ?>

    I am in the process of debugging another plugin problem and noticed that the debug file says that I am improperly calling the wp_enqueue_scripts function. Can anybody advise me on where to find the new code to enqueue the stylesheets so I can eliminate this error in the process of debugging a completely different issue.

    #4462

    samdobrow
    Participant

    FYI this is one of the error messages:

    mod_fcgid: stderr: PHP Notice: wp_register_script was called <strong>incorrectly</strong>. Scripts and styles should not be registered or enqueued until the <code>wp_enqueue_scripts</code>, <code>admin_enqueue_scripts</code>, or <code>login_enqueue_scripts</code> hooks. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.3.) in /home/content/02/9386202/html/wp-includes/functions.php on line 3622, referer http://utopiahoa.com/wp-admin/plugins.php?plugin_status=all&paged=1&s&w3tc_note=flush_all

    #4468

    middlesister
    Keymaster

    The code to enqueue the stylesheets look perfectly correct. If you look at the error message, it says that it was wp_register_script that was called incorrectly. Not wp_enqueue_style.

    You need to check the code for any javascript files. They need to be inside a function attached to a hook, just like the wp_enqueue_style() calls are.

    #4469

    samdobrow
    Participant

    Thanks, I will take a closer look.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Enqueue Stylesheets Error Log Messages’ is closed to new replies.