How can I make all the css in the twentyseventeen theme appear inline? I already tried putting the following in header.php:

    <?php include("/wp-content/themes/twentyseventeen/style.css");?>

and it did not work.

  • try simply 'style.css', as both are in the same folder – inarilo Aug 16 '17 at 4:50
  • I created a child theme of it, but I still use style.css from twenty seventeen. – NerdOfLinux Aug 16 '17 at 12:05
  • 1
    why do you want it inline? this talks about the correct way to enqueue parent and child themes developer.wordpress.org/themes/advanced-topics/child-themes. alternatively try '../twentyseventeen/style.css'since both folders are under the same themes folder – inarilo Aug 17 '17 at 11:37
  • Inline is supposed to be faster. – NerdOfLinux Aug 17 '17 at 15:49
  • Inlining "critical css" is faster, but probably not the entire stylesheet in the header. I'd recommend just putting the header/nav and critical css elements in there and take them out of the child css. I do hope you're working on a child of the theme and not the theme itself? If not, your changes will get removed every time you update. – Nathaniel Flick Aug 20 '17 at 10:54

For some reason, taking out the beginning / solved my issue:

    <?php include("wp-content/themes/twentyseventeen/style.css");?>

After doing this, I removed it because I realized how much slower it made the page load.

  • this might actually work, but you should never include with relative paths. – Mark Kaplun Sep 8 '17 at 15:59

Use wp_register_style()

// Include stylesheets
function stylename() {
    wp_register_style( 'stylename', '/wp-content/themes/twentyseventeen/style.css' );
    wp_enqueue_style( 'stylename' );
add_action( 'wp_enqueue_scripts', 'stylename' );
  • 4
    hmmm that is not inline – Mark Kaplun Aug 16 '17 at 5:48

If you want to make it inline:

        <?php $css_file = file_get_contents( 'http://yoursite.com/wp-content/themes/twentyseventeen/style.css' );
        echo '<style type="text/css">' . $css_file . '</style>';

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.