WordPress plugin enqueue scripts working for js, but not css files

The function wp_enqueue_style last argument is the $media and you set it to true so its mean you are doing <link rel=”stylesheet” … media=”1″ /> $media (string) (Optional) The media for which this stylesheet has been defined. Accepts media types like ‘all’, ‘print’ and ‘screen’, or media queries like ‘(orientation: portrait)’ and ‘(max-width: 640px)’. Default … Read more

How to remove all enqueued assets from the active theme?

Here you go. I took this out of my mailoptin plugin. Adapt the code to your use case. add_action(‘wp_enqueue_scripts’, function () use ($wp_get_theme) { global $wp_styles; global $wp_scripts; $wp_get_theme = wp_get_theme(); $child_theme = $wp_get_theme->get_stylesheet(); $parent_theme = $wp_get_theme->get_template(); foreach ($wp_scripts->registered as $key => $value) { $src = $value->src; if (strpos($src, “themes/$child_theme/”) !== false || strpos($src, “themes/$parent_theme/”) … Read more

How to add CSS via custom plugin?

Here’s your problem: wp_enqueue_style( ‘style’, get_stylesheet_uri() ); wp_enqueue_style( ‘slider’, get_template_directory_uri() . ‘test.css’, array(), ‘1.1’, ‘all’); Neither of those files are in your theme. get_stylesheet_uri refers to the style.css that has the themes name etc, and get_template_directory_uri is the URL of the parent theme. Neither of those are your plugin folder. You can confirm this by … Read more

How do I use a color from theme options?

You would simply call that option inside of a callback, and hook it into wp_print_styles or wp_head (either one is semantically correct in this case). First, set up your callback, which will print an inline style sheet: function wpse74013_print_custom_styles() { ?> <style type=”text/css”> </style> <?php } add_action( ‘wp_head’, ‘wpse74013_print_custom_styles’ ); The next step is to … Read more