Support » Developing with WordPress » wp_enqueue_style – dependency

  • Resolved Paul Guijt

    (@paul-guijt)


    I am experimenting with loading stylesheets.

    test.css :

    .test { background-color: aqua ; }
    

    functions.php:

            // Test.css
            wp_enqueue_style( 'test', get_stylesheet_uri(), array('style') );
     
            // Theme stylesheet.
            wp_enqueue_style( 'style', get_stylesheet_uri() );
     

    Why can’t I see the aqua background?
    I try to do it according to the Handbook.
    Ultimately I want to load a stylesheet before style.css.

    Thanks for any help!

    • This topic was modified 2 years, 9 months ago by Paul Guijt.
Viewing 2 replies - 1 through 2 (of 2 total)
  • get_stylesheet_uri() is just a quicker way of saying get_stylesheet_directory_uri() . '/style.css', so the test stylesheet isn’t getting loaded. You’ll need to call get_stylesheet_directory_uri() . '/test.css' to load the first stylesheet.

    Second, you still won’t get what you want, because setting a stylesheet as a dependency means that WP will load any stylesheets listed as a dependency first, so in your case, style will be loaded and then test.

    Thanks, Stephen, just what I needed.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_enqueue_style – dependency’ is closed to new replies.