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 trialWael Al-Akhali
Courses Plus Student 1,212 PointsChild theme creation has changed?
on https://codex.wordpress.org/Child_Themes they mention the following :
Note that the previous method was to import the parent theme stylesheet using @import: this is no longer best practice. The correct method of enqueuing the parent theme stylesheet is to add a wp_enqueue_scripts action and use wp_enqueue_style() in your child theme's functions.php. You will therefore need to create a functions.php in your child theme directory. The first line of your child theme's functions.php will be an opening PHP tag (<?php), after which you can enqueue your parent and child theme stylesheets. The following example function will only work if your Parent Theme uses only one main style.css to hold all of the css. If your theme has more than one .css file (eg. ie.css, style.css, main.css) then you will have to make sure to maintain all of the Parent Theme dependencies.
Who do we exactly follow the instructor or the website?
4 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHi Wael,
While I'm personally not that familiar with creating child themes, it good to remember that technology is rapidly changing and evolving. It looks like the video you are referencing was recorded approximately 2 years ago, so it's really not surprising the methods have changed. The video will still be relevant for most of the instructions, but if the codex says to do it differently, I would follow the codex and just chalk the difference up to evolving code.
Good job on noticing the difference. Keep coding! :)
Hugues Audouard
1,508 PointsHi, I've just started a treehouse trial. I was already aware of the change to the enqueuing method but surely when an important change such as this one occurs the training videos should be updated or at least an obvious note included to give students the correct information. Otherwise when one get to more advanced section how do we know your providing the latest information and best practice training ?
Winslow Jenkins
6,319 PointsI happened across the new best practice, too. Two hours later, I restart the video, my first child theme now functional.
As mentioned in an earlier post, this is the URL with the necessary info: https://codex.wordpress.org/Child_Themes
I was totally overthinking it. All I needed was to create a child theme folder, then add a style.css file with the header only and a functions.php file (not strictly necessary, but created it anyway) with the small bit of code the URL above mentions. It's actually quite easy!
Make sure the "Template" line in the style.css header is the same name as the parent template and the Theme Name is something you'll recognize, as that is what you'll see displayed in your theme chooser.
I tried to include the code for the functions.php file here, but it didn't display properly in the message window. Sample contents of both files are available in raw format here: https://premium.wpmudev.org/blog/how-to-create-wordpress-child-theme/
There is another version of the functions.php on the Wordpress site linked to above, too, and I tried both, but so far I can't tell a difference. Maybe someone who understands this better can help me to understand it as well? I hope this helps somebody and look forward to learning more from any replies.
Brigitta Nagy
380 PointsThanks so much for clarifying this, Winslow! I was definitely overthinking it, too - glad to see it's way simpler than it seems it should be... :)
Hugues Audouard
1,508 PointsHi, I've just started a treehouse trial. I was already aware of the change to the enqueuing method but surely when an important change such as this one occurs the training videos should be updated or at least an obvious note included to give students the correct information. Otherwise when one get to more advanced section how do we know your providing the latest information and best practice training ?