- This topic has 8 replies, 3 voices, and was last updated 3 years, 11 months ago by
Tom.
-
AuthorPosts
-
January 7, 2020 at 12:40 pm #1125014
Heather
Hi,
I have the GP child theme so that I can have custom stylesheets and functions.php sheets, and I am using .scss for my styles. My preprocessor creates a minified style.css sheet from the style.scss, but it does not seem to be registering.
The location of the new style.css sheet is generatepress_child folder > styles > style.css
I tried to enqueue it with a folder path in the get_stylesheet_directory_uri() but it did not work. Any suggestions for the code to use in my functions.php, or should I have the style.css file generated outside of that styles folder?
It seems like it keeps trying to look for the style.css sheet that comes with the child theme as I keep getting this error:
Warning: filemtime(): stat failed for …./wp-content/themes/generatepress_child/style.cssBut I obviously want to remove this stylesheet and only pull from my new one in my styles folder.
Thanks
January 7, 2020 at 2:24 pm #1125080Leo
StaffCustomer SupportHi there,
Does this help?
https://generatepress.com/forums/topic/how-to-make-sass-work-with-my-child-theme/Let me know ๐
January 8, 2020 at 8:20 am #1125854Heather
Hi,
This does not unfortunately. I already know that WordPress or any browser doesn’t read .scss files. I am already running a preprocessor and have a new style.css file that has been generated from the style.scss file. The problem is that I can’t seem to enqueue that new .css file, so I want to know what exactly I should put into my functions.php file in order to have this .css file loading.
I know I have to “register” it, but no code I am putting in is working. I am not sure if it is because the .css file is located a new folder called “styles” that is inside the child theme folder, but something isn’t catching.
Could you help me with this code? Just need to enqueue that new file instead of the theme defaulting to the style.css file that comes with the child theme.
January 8, 2020 at 6:18 pm #1126266Tom
Lead DeveloperLead DeveloperHi there,
Try this:
add_action( 'wp_enqueue_scripts', function() { wp_enqueue_style( 'your-handle', get_stylesheet_directory_uri() . "/styles/style.css", array(), filemtime( get_stylesheet_directory() . "/styles/style.css" ) ); } );
Let me know ๐
January 9, 2020 at 7:38 am #1126894Heather
That worked better! I didn’t have that filemtime part. However, I am still getting this warning at the top of my page:
Warning: filemtime(): stat failed for …/wp-content/themes/generatepress_child/style.css in …/wp-content/themes/generatepress/inc/general.php on line 35
So it seems like it’s still trying to load the style.css sheet that comes with the child theme. Do I have to change something in that general.php sheet?
This is what is on that line:
`if ( is_child_theme() ) {
wp_enqueue_style( ‘generate-child’, get_stylesheet_uri(), array( ‘generate-style’ ), filemtime( get_stylesheet_directory() . ‘/style.css’ ), ‘all’ );
}`Do I just need to update that to the /styles/style.css?
January 9, 2020 at 8:26 am #1126973Tom
Lead DeveloperLead DeveloperAh, you can just dequeue that stylesheet:
add_action( 'wp_enqueue_scripts', function() { wp_dequeue_style( 'generate-child' ); wp_enqueue_style( 'your-handle', get_stylesheet_directory_uri() . "/styles/style.css", array(), filemtime( get_stylesheet_directory() . "/styles/style.css" ) ); }, 50 );
January 10, 2020 at 7:26 am #1127957Heather
Unfortunately it is still giving me the same warning. I tried changing the ‘generate-child’ to ‘style.css’ but that did not work either.
Other suggestions? Change the code on that line directly? try a different target to dequeue?
January 10, 2020 at 7:29 am #1127959Heather
Actually nevermind, I think it is fine – I literally removed the style.css sheet from the generate-child theme folder and it caused the warning to come up, but when I added it back and inspected my styles I can see that they are loading from the styles/style.css
So I think it is working as intended?
January 10, 2020 at 8:50 am #1128024Tom
Lead DeveloperLead DeveloperYep, that should work fine – having the file there should prevent the warning, and the code above should make sure it doesn’t actually load on your website.
-
AuthorPosts
- You must be logged in to reply to this topic.