-1

I'm designing a custom Theme using the underscores.me template. I've read several different "my css doesn't load" articles on this topic, but none seem to help w/ my issue.

My own styles will load via wp_get_template_directory_uri().'/style.css', while-- even with bootstrap.min.css etc stored locally (e.g. ./css/bootstrap.min.css), where wp_get_template_directory_uri().'/css/bootstrap.css' would be used in the code, and does show in view browser source-- it's still not loading as evidenced in Chrome developer tools sources (and as is visible when rendered).

If i use Chrome dev'r tools to view source, and click the <link href="whatever_file" />, the file opens. So, it's not a matter of my paths being incorrect.

If I hard code my html as an HTML file, the styles are loaded. Hybrids of html / php also load the CSS. But, when I try to go "by the book" for theme development, it doesn't load.

If I use the 'Additional CSS' option in the customizer, and use e.g. @import url('http://site.local/wp-content/themes/theme_name/css/bootstrap.min.css'); it does in fact render the page w/ the bootstrap CSS as desired, but that doesn't seem correct to me. What might I be doing wrong here?

2
  • If you can see link href in the source at all then wp_enqueue_style() is working. If fact, that’s the only thing it does. So if it’s done that and the URL is correct then the only issue can be the CSS. What makes you think it’s not applying? Are you sure the styles just aren’t being overwritten by another stylesheet? Commented Sep 19, 2022 at 9:28
  • I see what the issue is. <link rel="<?php... instead of <link rel="stylesheet" href="<?php... As was in my header.php file. I too often trust the regex when updating multiple files after copy paste etc. Clearly, it was easy to overlook. Didn’t notice it when I did view source as described in o/p, for my eyes going straight to the URL’s (missing the attribute designation). Here, i witness my own embarrassment. Alas, the shame of it all! Commented Sep 20, 2022 at 3:33

1 Answer 1

-2

As stated in my last comment, above.

SOLVED:

In the theme header.php file, I had erroneously entered

<link rel="<?php...

instead of

<link rel="stylesheet" href="<?php...

... note missing href attribute in the former.

In any case, at this time, I would say my entire approach was probably incorrect. I believe the stylesheet should be linked instead via call to wp_enqueue_styles in the Theme functions.php file.

Correct? I'm still learning this stuff, clearly!

best regards!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.