From the course: WordPress: Building Child Themes
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Best practices for including stylesheets - WordPress Tutorial
From the course: WordPress: Building Child Themes
Best practices for including stylesheets
- Right now, we have perfectly adequate code that loads both CSS files. But, we can actually improve the quality of our code and learn a bit about WordPress and PHP in the process. So let's look at how to do that. The first thing I want to do, is I want to force WordPress to load the parent theme's CSS file first. So what we can do here is I'll go to the end of this line, I'll add a space and then a comma, and I'm going to type in array, followed by a parentheses, followed by a single quote, and then type in parent-style. Whenever I type array, think of a list. I'm giving WordPress a list of data. In this case, it's only a list with one item, but some functions in PHP require that list format. So I'm giving WordPress a list with the names of files that it should load before loading my file. The name here has to match the name of the file when we included it in WordPress, so right here. Right now, WordPress must load this parent-style first, which is exactly what we want. There's one…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
- Ex_Files_WordPress_Building_Child_Themes_Starting_Site.zip
- Ex_Files_WordPress_Building_Child_Themes_2.zip
- Ex_Files_WordPress_Building_Child_Themes_3.zip
- Ex_Files_WordPress_Building_Child_Themes_4.zip
- Ex_Files_WordPress_Building_Child_Themes_5.zip
- Ex_Files_WordPress_Building_Child_Themes_6.zip
- Ex_Files_WordPress_Building_Child_Themes_7.zip