Enqueue styles through the wp_enqueue_style function vs link tag inside header.php

Three good reasons to use the enqueue functions over hard coding are to eliminate duplication, avoiding library conflicts, and handling dependencies: Duplication: If, for example, you hard code a link to jQuery, and then install a plugin which also enqueues the jQuery library, you’re site will be loading the same library twice, which will affect … Read more

Enqueue a css using negative conditional tags

The bug’s only 4 years old so you wouldn’t want to rush them would you?! A workaround is to leave out the wp_style_add_data() and use the ‘style_loader_tag’ filter: add_filter( ‘style_loader_tag’, function ( $tag, $handle ) { if ( $handle == ‘purecss-all-not-ie’ ) { $tag = “<!–[if gt IE 8]><!–>\n” . $tag . “<!–<![endif]–>\n”; } return … Read more

How Would You Enqueue A Google Web Font?

You should be able to just use http://fonts.googleapis.com/css?family=Rosario:400,700,400italic which is the “combined” URL given by Google when selecting multiple weights/styles of a font. You can then just register the font once. You don’t need to over-complicate the $handle either, something like google-fonts-rosario should do just fine as long as it is unique as mentioned in … Read more

How to add extra attribute to stylesheet link?

We can use style_loader_tag filter to filter the link that is being output. Here is the filter: $tag = apply_filters( ‘style_loader_tag’, “<link rel=”$rel” id=’$handle-css’ $title href=”https://wordpress.stackexchange.com/questions/231597/$href” type=”text/css” media=”$media” />\n”, $handle, $href, $media); Here the link $handle for which you want to add attribute is font-awesome so if the handle, so you can replace font-awesome-css with … Read more

wp_enqueue_style for Plugin with multiple stylesheets

To answer your first question, you would use the second style, i.e. function add_my_stylesheet() { wp_enqueue_style( ‘myCSS’, plugins_url( ‘/css/myCSS.css’, __FILE__ ) ); wp_enqueue_style( ‘myCSS1’, plugins_url( ‘/css/myCSS1.css’, __FILE__ ) ); } add_action(‘admin_print_styles’, ‘add_my_stylesheet’); What the add_action() function does is tell WordPress, “When the admin_print_styles action occurs, run this add_my_stylesheet() function.” Confusingly, the practice of using the … Read more