Skip to content

A Beginner’s Guide to WordPress Theme Development: Day 2

[bg] continues on [wp] with a look at the two most important files in any WordPress theme: the index.php and style.css files.
  • Day 1: Introduction, the fundamentals of WordPress theme development
  • Day 2: The index.php and style.css files: the most important parts of any theme.
  • Day 3: The header.php, sidebar.php and footer.php files.
  • Day 4: The single.php file: the file that handles posts.
  • Day 5: The archive.php, home.php and functions.php files and a wrap up of all that has gone on. You will also be able to download the whole series as an eBook.

download

After the excitement of learning about template files yesterday, it’s time to move and look at the most important files of all WordPress themes: the index.php and style.css files.

First off, the style.css. This is our stylesheet. As I said yesterday, this isn’t a design series, so I’m not going to dwell on it too much, but there are some important parts of a stylesheet which WordPress needs that tell it some info about the theme. The theme we’ll be creating this week is called Champion (download above). It’s based on the Default WordPress theme for ease of use. Download the theme and unzip it. Open up the style.css file and you’ll see something like this:

/*
Theme Name: Chamption Theme URI: https://wpshout.com
Description: description
Author: Alex Denning
Author URI: https://wpshout.com
Version: 1.0
*/

And that’s all you need to make a stylesheet WordPress-ified. Moving on, the index.php file:

WordPress has something called a file hierarchy which means it will look for a file specific to the page first, but if it can’t find it then it will use the index.php file. For example, posts have a hierarchy like so:

Yay! 🎉 You made it to the end of the article!
Alex Denning
Share:

4 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
anthony
October 31, 2009 12:42 pm

Thanks for putting together this series. Much appreciated. I’m running WP 2.8.5 locally. When I preview the Champion Theme before I activate it, I’m getting an error on line 96 of index.php. Any ideas?

Pedant
September 2, 2009 12:45 am

I think you mean “pedant” not pedantic 🙂

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!