Having a basic WordPress theme template is a helpful resource if you’re creating custom themes and a good place to start if you’re new to WordPress theme development. We’re going to be focusing on WordPress theme development and assume that you’ve already managed to get a WordPress site up and running.

Themes are installed inside wp-content/themes/ in your site’s parent directory. A theme needs two files to be valid: index.php and style.css. If we make a directory inside wp-content/themes and it has these two files then we’ll be able to select it from the appearance menu inside our site’s administrative portal.

The next two files we’ll put inside our theme’s directory are header.php and footer.php. These two files will contain our HTML doctype, head and body tags and will get called from within index.php using the get_header() and get_footer() functions. We will need to insert the wp_head() function inside header.php right before the closing head tag.

If we’re using HTML5, we’ll want these two files to look something like the following. Note: we are using the get_template_directory_uri() function here to retrieve our template’s URI so that we can access our theme’s style.css file.

header.php

footer.php

Now we are ready to work on our index.php file. The content of this file will be the first thing we see when we go to our site. We’re going to breakdown the following PHP code to learn the basics of WordPress’s ‘The Loop’, the system in which posts can be queried and displayed. We’ll omit HTML tags from this example for clarity, but keep in mind that would be the next step.

The first line is using the query_posts() function to query all of our posts for the parameters set within the parentheses. These parameters can be read like so: get seven posts in ascending order from category 5. You can find out your category’s ID by selecting it in the categories menu inside your site’s administrative portal, it will be displayed inside the URL and should look something like taxonomy=category&tag_ID=5.

The second line is our loop. It starts off with the have_posts() function which is true or false depending on if there are posts or not. If true, while (have_posts()) will cycle through each post and from this loop we can use different functions to grab whatever we want from each individual post. The following is a list of some of the basic functions you can use within the loop.

the_title()
the_content()
the_tags
the_excerpt()
the_category()

All of the PHP functions we’ve been using are the standard WordPress functions. You can find the entire function reference here: http://codex.wordpress.org/Function_Reference