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 trialLuke Travis
2,887 PointsChild Themes and loading CSS using wp_enqueue_style
Hi all! In the "Linking CSS Video" of "How to Build A Wordpress Theme", Zac talks about using wp_enqueue_style to load up the css files.
I'm curious if the wp_enqueue_style method of file upload will work with child themes.
For instance, if, in the parent theme, I am using this script in the functions.php file
wp_enqueue_style('main', get_template_directory_uri() . '/style.css');
and, in the child theme, I am using @import to call the stylesheet from the parent theme like so
@import url("../name-of-parent-theme/style.css");
...will the styles in the child theme load correctly and independently of those that aren't in the parent themes across my site?
1 Answer
Chris Shaw
26,676 PointsHi Luke,
You can use the built in WordPress enqueue
functions anywhere you like, as long as they don't have conflicting names when you queue them up they will output into the page source without any issues, in your case the parent theme would queue it's assets first then the child theme will have it's turn.