Chapter 4: WordPress Theme Essentials

IF YOU WANT to do more advanced stuff with WordPress, you need to understand theme essentials. You could just start hacking the default theme or download any other quality theme and go from there, but there are some things that might not be obvious from just using and tinkering with the code if you're new to WordPress. This chapter helps you dive into the WordPress theme concept to get acquainted with themes and how they work. You'll learn how to alter them to fit your needs. After doing that, you'll be able to put your knowledge to good use in the coming chapters.

In this chapter, you'll build a theme from scratch and learn more about the various template files. Those files include the style sheet and the fairly extensive functions.php file, so you can learn how to work with all those elements you encountered in the previous chapters.


You may already be somewhat familiar with WordPress themes and the premises under which they operate. In theory, themes are a way to separate the design from the code, but in reality, there is still a lot of coding happening in the more advanced themes out there.

A theme consists of a folder with template files and any other files that may be needed. The only two absolutely necessary template files are style.css and index.php. The former contains the header that identifies your theme (and generally some styling code), and the latter is the basic layout. If you're looking for a challenge, try to ...

Get Smashing WordPress: Beyond the Blog, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.