0

I am trying to get my CSS files to load after the theme and plugins have been loaded using add_action(after_setup_theme, add_css_js, 100000)

function add_css_js(){
    wp_enqueue_style(
        'color',
        trailingslashit( get_theme_root_uri() ) . 'gemtechllc/css/color.css' 
    );
    wp_enqueue_style(
        'gem',
        trailingslashit( get_theme_root_uri() ) . 'gemtechllc/css/gem.css'
    );
}
add_action( 'after_setup_theme', 'add_css_js', 100000);
4
  • 1
    You need to show us what is in this function: add_css_js. And the add_action needs to be like this: add_action('after_setup_theme', 'add_css_js', 100000); Commented Jun 6, 2020 at 21:34
  • 2
    If you're loading CSS files, you should be using wp_enqueue_style(), which allows you to define your CSS file's dependencies. Commented Jun 6, 2020 at 21:49
  • function add_css_js(){ wp_enqueue_style( 'color', trailingslashit( get_theme_root_uri() ) . 'gemtechllc/css/color.css' ); wp_enqueue_style( 'gem', trailingslashit( get_theme_root_uri() ) . 'gemtechllc/css/gem.css' ); } add_action( 'after_setup_theme', 'add_css_js', 100000); Commented Jun 7, 2020 at 0:19
  • For future reference, it's preferable to edit your question to add context, rather than providing it in comments (especially if you're adding code samples, since they're very difficult to read with no formatting applied). Commented Jun 8, 2020 at 21:26

1 Answer 1

0

Sorry I am unable to comment so I have to post here.

I will give this answer as some examples and then hopefully you can use in your situation or provide further information about your exact setup.

Make sure you are using a child theme (If you are unsure about what this is please read this

In my sites I find I am using storefront a lot so an easy way to start off with child themes would be to give this one a try

Ok so now that we are on the same page in your Child theme functions.php add or un comment the following:

/**
 * Dequeue the Storefront Parent theme core CSS
 */
function sf_child_theme_dequeue_style() {
    wp_dequeue_style( 'storefront-style' );
    wp_dequeue_style( 'storefront-woocommerce-style' );
}

Once you have that done you can add any css to your stylesheet (style.css) or even add css from within your function pages.

I really hope this helps!

If not please provide details of the theme and the function you are trying to use / call.

Cheers,

2
  • Hello, Well I hate to say it, but that caused other issues. Commented Jun 8, 2020 at 2:51
  • OK, Can you please start off by providing the information Myself and the others have asked. we can only provide really general ideas otherwise. What theme are you using Please provide the function "add_css_js" Commented Jun 8, 2020 at 19:26

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.