Question

When using stylesheets I like to use wp_enqueue_style to have wp handle the loading. For some reason this works perfectly fine when I am logged in. But when I am not logged in the include statment gets wrapped in html comments, thus the browser doesn load the stylesheet. When loading I use: wp_enqueue_style("a-unique-name-style", plugins_url('/css/filename.css',path);

I also tried

function name_enqueue_style() {  
    error_log(__LINE__);
    wp_enqueue_style("a-unique-name-style", plugins_url('/css/filename.css',path));   
    error_log(__LINE__);
}
add_action( 'wp_enqueue_scripts', 'name_enqueue_style' );

But name_enqueue_style does not load at all. (Nothing in the error log either.)

I run this from both the plugin "main" php as from functions that build widgets.

What is happening? I don't even know where to start looking.

Was it helpful?

Solution

as Tom J Nowell asked in the comments a caching plugin was the culprit. In this case WP Fastest cache. Just deleting the cache did not work. Turning the caching off and on again fixed the problem.

update: I did some more digging and the fact it gets commented is correct. The caching plugin also runs a code minimizer. For some reason the minimized code did not use the stylesheet I added. Turning it off and on again forced a rerun of the minimizer (I guess).

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top