0

Really basic, I'm afraid. My scripts aren't loading when I put them as part of a function triggered by the wp_enqueue_scripts action in functions.php. If I put them outside of that action as part of the main file, they load fine, but of course this is bad form. So:

wp_enqueue_style( 'intranet-style', get_stylesheet_uri() );

works but throws up errors in debugging but

function intranet_scripts() {
    wp_enqueue_style( 'intranet-style', get_stylesheet_uri() );
}

add_action( 'wp_enqueue_scripts', 'intranet_scripts' );

does nothing, it doesn't even throw up any errors. I must be missing something super basic but I can't for the life of me see what it is. Help?

2

get_stylesheet_uri() loads the main stylesheet of the theme. If you need to load additional stylesheets, you need to use get_template_directory_uri() for parent themes and get_stylesheet_directory_uri() for child themes.

If you have stylesheet called custom.css in the root in a child theme, you will use get_stylesheet_directory_uri()' . /custom.css'

You should also make sure that you have wp_head() inside your <head></head> tags in your header

  • It was the missing wp_head() that was doing it, thanks. – SinisterBeard Sep 10 '15 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.