Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Russell Comer
Russell Comer
26,102 Points

@import not working

I've tired importing the style.css file from the parent theme into my child theme like this:

@import url('.../wp-content/themes/mytheme/style.css');

and no matter the numerous ways I try to do this it will not import the css into the website.

Help please

8 Answers

Russell Comer
Russell Comer
26,102 Points

so apparently I had the child theme folder named neuro child and when I changed it to neuro-child it worked. Its always something so simple. Thank you so much for your help its greatly appreciated.

Russell Comer
Russell Comer
26,102 Points

Yes it is in the child directory, and Im only using two rather than three? not sure

Double check to make certain you're using:

@import url("../mytheme/style.css");

rather than

@import url(".../mytheme/style.css");

I ask since in your original post, you have three periods proceeding the /

Russell Comer
Russell Comer
26,102 Points

this is what Ive been putting in exactly:

@import url("mywebsite.com/clickandbuilds/WordPress/mywebsite/wp-content/themes/neuro/style.css");

Hmmm. You should only need the follow:

@import url("../neuro/style.css");

This tells the file to find the file up one directory to themes, then down into the neuro folder (which I assume is the parent theme) to find the parent theme's style.css.

I'm not certain of your directory structure, but if your child theme CSS file, style.css is in its own folder within the themes folder, try the following:

@import url("../mytheme/style.css");
  • mytheme folder
  • mytheme-child folder
    • style.css
Russell Comer
Russell Comer
26,102 Points

Thats what I have no matter what I do it will not import the style to the web page. I have the style.css within the child theme folder and within the that css file i have the @import rule for the css file with the parent theme. How exactly am I suppose to write out the directory everyone has a ... do I start it with the http://mywebsite.com/wp-content/themes/mytheme/style.css or am I doing that wrong. Ive copied and pasted the directory from my ftp and added the http:// followed by my website then at the end I added the style.css, Ive spent hours on this I'm ready to give up on it.

Hi Russell,

Hang in there! I realize it can be frustrating - all of us have been there.

So, if your parent theme CSS is at: mywebsite.com/wp-content/themes/mytheme/style.css

is your child theme CSS : mywebsite.com/wp-content/themes/mytheme-child/style.css ?

I assume that the style.css you're writing the import in, is in the child directory?

Also, you're using only two .. rather than three, correct?

Anytime! Good luck, and enjoy rest of the course.