Let’s build WordPress theme – part 1

Booyah, we will do it! We will create sample WordPress theme from a scratch. It will be object oriented, clean code… I hope! Anyhow, we will learn a lot in this course. All right, let’s do it.

WordPress setup

This is the easiest part. If you want to write a theme, you must know how to install WordPress instance. You can do it on remote server, on your local machine – it is up to you. Just make it clean installation – we do not need any 3rd party to interfere with our project.

Theme directory

As you may know, theme directory for WordPress is /wp-content/themes/ and we will work with it. Of course we need to create subdirectory for our theme. Let’s call it… Well… Let’s call it “booyah”!

Theme files

To see something, we need just two files – it is absolutely minimum. It is style.css and index.php. First of all, create those two empty files in booyah subdirectory. Your file structure should looks like this:

/wp-content/themes/booyah/style.css
/wp-content/themes/booyah/index.php

style.css

This file will contain some basic theme info. Put here those lines:

index.php

This file will produce output for our theme. Put here those lines:

Important

This is a very bad example. You can consider it as an example of how not to do this. But… it works! It works and it is very easy. As you can see, WordPress theme can be built on such small effort so it is dangerous. It is dangerous, because there are plenty of bad written themes around the Internet.

What’s next?

You can download booyah-0.1.1, if you don’t want to copy and paste examples below. Activate it and voila – it works! But you just wait for part two… There will be much more booyah! than this, I promise.

Be the first to comment

Leave a Reply

Your email address will not be published.


*