The symptoms of my problem are different from other similar questions, on this forum and others.

I'm using a local instance of WP, using the 33 theme, on XAMPP, and with a virtual domain, something like "http://mywordpresssite/". The site works well, other than for the following problem.

Given my enqueue code in my functions.php:

// load css into the website's front-end
function mytheme_enqueue_style() {
    wp_enqueue_style( 'mytheme-style', get_template_directory_uri() . '/css/zzz.css' ); 
add_action( 'wp_enqueue_scripts', 'mytheme_enqueue_style' );

When I view the source code after reloading the page, the <link /> tag will show up in the header, but ONLY IF THE .css FILE DOESN'T EXIST! If I rename my /css/zzz.css to /css/yyy.css the line will show correctly in my html source. Of course, since the file doesn't exist, the link tag doesn't do anything, because it's linking a non-existent style sheet. If I rename my style sheet file correctly to zzz.css, then for some reason the enqueue doesn't actually load that line into the header, and when I view the html source code, the link to my custom css isn't there. It fails if the file actually exists.

I am stumped. I can do this in other local instances of WP, just not this new site I'm working on.

If I output the custom style sheet path, it outputs correctly:

echo get_template_directory_uri() . '/css/zzz.css';



...but, of course, trying to enqueue my custom style sheet does nothing.

  • 2
    disable all plugins. if not solved, the problem is with your theme – Mark Kaplun Mar 7 '18 at 15:55
  • 1
    are you using a child-theme? if so, change: get_template_directory_uri to get_stylesheet_directory_uri – admcfajn Mar 7 '18 at 16:23
  • I think the theme is doing something to prevent the loading of custom scripts. There is, however, an /assets/ folder, with a /css and /js folder, and inside the /css folder is a custom.css. I guess that's what I'm going to be forced to use. – TARKUS Mar 7 '18 at 18:18
  • Because scripts and styles are enqueued with URLs WordPress can't really check if the file exists before doing anything with them (without making HTTP requests to every resource before enqueueing), so it doesn't. They are just enqueued blindly, so it doesn't make sense for different behaviour based on whether the file exists or not. There must be a 3rd-party plugin or theme interfering. – Jacob Peattie Mar 8 '18 at 8:02
  • @JacobPeattie For now my conclusion agrees with yours. Some plugin, or possibly the theme itself, is preventing the loading of my own css. In the mean time I've found an assets/css/custom.css file that I suppose will allow me to do what I need to do. – TARKUS Mar 9 '18 at 11:18

Browse other questions tagged or ask your own question.