Using dependencies in wp_register_style() for wordpress

I am trying to get a custom css file to load after the plugin stylesheets. I was thinking I could use the $deps parameter of wp_register_style(), but the css file does not load at all when I add the array(). This happens no matter what is included in the $deps array(), ie (array(‘style’)
, array(‘style.css’)).

Is there an issue with the call, or a better way of doing this?

Read More

In my functions.php

// Load custom css
add_action('wp_enqueue_scripts', 'prefix_add_my_stylesheet');

function prefix_add_my_stylesheet() {
    wp_register_style( 'custom-supersized-styles', get_template_directory_uri(). '/css/custom-supersized-styles.css', array('style','supersized');
    wp_enqueue_style( 'custom-supersized-styles' );
}

Related posts

Leave a Reply

1 comment

  1. If you’re using the WP Supersized plugin try registering your function like so:

    // Load custom css
    add_action('wp_enqueue_scripts', 'prefix_add_my_stylesheet', 999);
    

    The dependencies array (the parameter you’re attempting to use to add supersized with) depends on supersized having already been registered by WordPress. If you set the priority of your own prefix_add_my_stylesheet to a higher number, it should then load after the plugin has registered and loaded its CSS (and thus will be available).

    In addition, you can remove the style as a dependency. (style is never registered by WordPress as a dependency handler, and your enqueued scripts / css should be loading after style.css loads anyway).

    Hope that helps!