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

Jon Edwards
Jon Edwards
7,913 Points

Why is the style.css file the only file needed to make the theme function?

If you look at all the other theme folders, there are many files. Yet with only the css and png files, the child theme functions. Are the other theme data all imported through the .css file? He never explains what's going on here. Sorry if this has been asked before.

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

This is just a quirk of how WordPress works.

It's complicated to go through specifics but WordPress files come together through a structure called the WordPress Template Hierarchy. The Hierarchy is a process behind the scenes that tells WordPress which templates to use according to which template files are included in your theme (and selected in the page admin). Once you understand the hierarchy you'll appreciate a little bit more why you only need a few basic files in your theme for WordPress to recognise a theme in the admin area.

Of course, it takes more than 3 files to make a good WordPress theme but to get you started you just need

  • screenshot.png - a file of that specific name which is an image file that the Theme Customiser displays for your theme
  • styles.css - This is where the meta data that identifies your theme goes as well as the main CSS styles for your theme.
  • functions.php - This can be empty for the time being but it is needed for WordPress themes to be recognised in the admin area.

I hope this helps understand what files are required as a minimum for Wordpress themes and how it works together.