This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

modifying priority for child theme stylesheets

  • Creator
    Topic
  • #8083
    srumery
    Participant

    I have a css file that I want to enqueue after the child theme style.css. In the framework documentation you show how to add a file between the framework style.css and child theme style.css by using a priority between greater than 5 and less than 10.

    My goal is to get this new stylesheet referenced after the child theme style.css file. I am using 10 as the $deps parameter when enqueueing the file.

    add_action('wp_enqueue_scripts', 'child_theme_skins', 10);

    Even thought I am calling it with a priority of 10, it is still getting called before the child theme style.css file. In that same article you say “style.css is hooked in a function with standard priority 10.” Since they have the same priority, I can’t seem to get my new file to be called after it. Can I change the priority of your function to enqueye style.css at 9 instead?

    Maybe there is a better approach. What would you recommend?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #8084
    Jason Bobich
    Keymaster

    It sounds like you’re maybe getting mixed between the $priority parameter of add_action() and the $deps parameter of wp_enqueue_stylesheet().

    Here’s one way I think you could accomplish what you want:

    function child_theme_skins() {
    	wp_enqueue_style( 'example-skin', get_stylesheet_directory_uri() . '/myfile.css', array('themeblvd_theme') );
    }
    add_action( 'wp_enqueue_scripts', 'child_theme_skins' );

    The id “themeblvd_theme” is what Jump Start uses to enqueue style.css, and so that’s what you want to be in the $deps of your enqueue’d stylesheet. Basically, this is an array of the stylesheets you want to come before your’s.

    http://codex.wordpress.org/Function_Reference/wp_enqueue_style

    So, now you’ll have:

    1. Framework stylesheets
    2. Style.css (which has framework stylesheets as its $deps)
    3. Your stylesheet (which has style.css as its $deps)
    #8088
    srumery
    Participant

    You are exactly right. I was confusing the two. I applied your fix and everything is lining up properly.

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.