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 How to Make a Website with WordPress Customizing WordPress Themes How to Make Child Themes

Gavin Cooper
Gavin Cooper
199 Points

@import function not recommended by WP

Doesn't WP now recommend not using the @import and instead use the functions.php using the wp_enqueue_style fucntion to load the child theme style.css file?

5 Answers

Craig Watson
Craig Watson
27,930 Points

Hi Gavin,

It absolutely does yes and this is the correct way to do it. I think the vid is a little old to be fair and it was not a "bad" thing to do at all before it is just a better thing to do by adding it to the functions file.

Craig

samtruss1986
samtruss1986
11,772 Points

Hello all, another resource here for you to have a look at if your still a little confused. I found this on youtube and followed the video. The tutorial worked for me and just thought I'd pass on the information. (NB: I'm not the author of the video or associated with it in any way.)

https://youtu.be/hylRE3COu4I?t=11s

Personally I think it's shameful that treehouse just adds a "note" to the bottom and lets us figure it out for ourselves, this video is about two years old now (possibly three). It wouldn't take them much time to set up a camcorder and add a link to the updated video in the teachers notes. I mean it doesn't have to be the same instructor or fancy, just a 3 minute video explaining the change, why and how to implement it.

LAZAR Istvan
LAZAR Istvan
2,887 Points

Thanks for the link brah, very useful.

Gavin Cooper
Gavin Cooper
199 Points

Thanks for the clarification Craig - I was wondering.

To be fair the @import is a much simpler way to do it for beginners like myself until I learn how to use functions :)

Leslie Askew
Leslie Askew
443 Points

https://www.smashingmagazine.com/2016/01/create-customize-wordpress-child-theme/ is a good resource.

Create a function.php file alongside the other two that reads:

<?php

add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );

function enqueue_parent_styles() {
   wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}

This workaround should be highlighted in the Notes.

Leslie Askew
Leslie Askew
443 Points

Hi m k

No! Hopefully they're not out too of date; I've just found this one bug. It cost me a day and much aggro but I'm still learning, so that's got to be a bonus! Good luck and hope you get on well with learning themes.