Enqueue Style for a page/pages only

It should work like this. Sidenotes: I don’t know why you deregister a stylesheet and register it again. Also: get_bloginfo(‘template_directory’) is now replaced by get_template_directory_uri(). Third: Are your folders really named with dots in between? Maybe this causes problems. And maybe your ui stylesheet is an dependency of the main jquery ui stylesheet. You should … Read more

wp_enqueue_style will not let me enforce screen only

I found the answer. Roots has a roots_clean_style_tag that limits everything except print as a media type. I updated mine slightly to just allow screen as well: function roots_clean_style_tag($input) { preg_match_all(“!<link rel=”stylesheet”\s?(id='[^’]+’)?\s+href=”https://wordpress.stackexchange.com/questions/95293/(.*)” type=”text/css” media=”https://wordpress.stackexchange.com/questions/95293/(.*)” />!”, $input, $matches); // Only display media if it’s print if($matches[3][0] === ‘print’){ $media=” media=”print””; } elseif ($matches[3][0] === ‘screen’){ $media=” … Read more

Enqueue stylesheets with the same name

Use a different handle for your stylesheet, maybe shortcodes-child and set the parent handle as dependency: wp_register_style( ‘shortcodes-child’, get_stylesheet_directory_uri() . ‘/stylesheets/shortcodes.css’, array( ‘shortcodes’ ), ‘1.0’, ‘all’ ); wp_enqueue_style( ‘shortcodes-child’ ); The file name of your stylesheet and the enqueue handle can be different.

Include user defined styles without including wp-load

If you are going to enqueue a stylesheet you should be using wp_enqueue_scripts not wp_print_styles, but you are in a bit of a gray zone between doing things “WordPress-ie” and doing things correctly for performance. The “WordPress-ie” way is to enqueue a stylesheet, but from a performance standpoint you are loading an additional resource and … Read more