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

Best practices for including stylesheets - WordPress Tutorial

From the course: WordPress: Building Child Themes

Start my 1-month free trial

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…

Contents