0

So I have an interesting dilemma here. My understanding is that best practice is to load up stylesheet, including Bootstrap css and javascript via functions.php file. However, in the header.php file the stylesheet snippet has this:

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />

The "this" that I refer to is the media="screen". If I am not mistaken this is part of the @media rules, but I am not sure if it will be necessary for refactoring this site into a bootstrap mobile responsive site.

Otherwise, I would just eliminate it and place this piece of code:

wp_enqueue_style('stylecss', get_stylesheet_uri());

into the functions.php file. My question being, am I going to mess things up for me down the line when I implement bootstrap templates by eliminating the line of code in the header for the sake of WP best coding practice?

3

wp_enqueue_style has a 5th parameter that represents the media attribute. https://developer.wordpress.org/reference/functions/wp_enqueue_style/

You could do the following to load this correctly:

wp_enqueue_style( 'stylecss', get_stylesheet_uri(), array(), false, 'screen' );

Hope it helps!

  • This is correct. If you need to make sure that stylesheets load in a certain order, use the third parameter ($deps) to specify the handles of all stylesheets which must load first. – Kenneth Odle Jun 16 '17 at 0:56

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.