1

I was expecting to see get_stylesheet_uri() called somewhere in the default header.php file for the default themes (2012-14), but anything like it is missing, which has me wondering how the reference is added.

The default theme headers have something like this:

<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width">
    <title><?php wp_title( '|', true, 'right' ); ?></title>
    <link rel="profile" href="http://gmpg.org/xfn/11">
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    <!--[if lt IE 9]>
    <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js"></script>
    <![endif]-->
    <?php wp_head(); ?>
</head>

Looking at the source for the themes, shows a proper link to the stylesheet in the header, so, how does it get there?

1 Answer 1

2

The stylesheet is registered and enqueued by a function called twentyfourteen_scripts() in the theme's functions.php. Callbacks hooked into the style loader/dependency system will be echoed on the wp_head action in the wp_head() function.

Which, by the way, is how you should be loading your own stylesheets. There is a similar system for scripts.

Your Answer

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

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