Hi @cramdesign, I feel your pain!, Try putting the type.css in the root folder of the theme to discard path issues first.
Matias, dear friend, a solution!
I had tried that but in the spirit of an honest response, I tried putting the css in the root folder but this time I tried a different css file. It worked! So I tried the file I actually wanted, didn’t work. The difference? The file I wanted to use loaded a google font with an @import rule at the top. Removing this line completely fixed the problem.
Solution:
1. remove the @import rule from the css file
2. Load the font in the admin like so:
add_editor_style( array( 'https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap', 'css/type.css' ));
and in the frontend via a similar method with my other stylesheets:
wp_enqueue_style ( 'font', 'https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap', false );
I am assuming that when the stylesheet was loaded and parsed to be used in Gutenberg, the @import rule was throwing an error that I didn’t know how to see or silently. I would love to know other people’s experience but I have an easy and elegant solution.
Thanks again to Matias.
-
This reply was modified 6 years, 1 month ago by
cramdesign.
@import use in the WP environment has been discouraged for a long time. I’m unaware when it started to actually cause issues, probably when the block editor was introduced. Directly enqueuing all style files is good practice whether @import works or not.
When you post code in these forums, even brief CSS statements, please demarcate with backticks or use the code button. When you use @import without doing so you actually cause an email notification be sent to forum member “import”. @ referencing other members who are not participating in the topic is strongly discouraged and is considered to be a sort of spamming. I know that was not your intent and the effect was unintentional. You couldn’t have known this, but now you do 🙂
Good job @cramdesign ! Keep up the good work.
Yikes. No, I certainly didn’t mean to mention the user named import. I feel sorry for that person. I will be more careful in the future.
Thanks again.