WordPress has become the most popular blogging platform for a while now, and you’re probably using it if you write on a self-hosted blog. One of the key reasons of WordPress success is its templating system. In fact, thousands of free WordPress themes are available on the Internet. However, if you want a truly unique theme, you’ll need to create your own. This article will give you a basic understanding of a WordPress theme’s structure.
WordPress themes are the standard layout system that define your blog’s appearance. It consists of template files, functions, template tags and images. To install a WordPress theme, you just need to upload it and activate it in your WordPress admin.
WordPress page structure
Most of the time, a WordPress page is composed of the header, the sidebar, the content and the footer. These structural elements usually are separated files that you can include in your template files. There can be more structure elements, such as other sidebars, advertising space or whatever you can think of.
The above chart shows what files are used depending on the page you are using. You can use only the index.php with a stylesheet, but you would be missing customization options that make your theme more user-friendly.
In WordPress, the loop is a set of functions used to display your posts and everything related to the posts (title, tags, author, categories,…). To customize the loop, WordPress has some well documented pages that you’ll find here or here. For a more advanced loop use like multiple loops on the front page, some blogs offer very extensive tutorials about it.
Template tags are small PHP snippets that are used to display info on the blog. For example, <?php bloginfo(‘url’) ?> will display the base url of your blog. WordPress has a very good documentation about template tags and lists the tags available. When using WordPress plugins, you’ll sometimes get plugin specific template tags.
The functions.php file is a special one, it will not display a specific page but contains all functions used for your template. For example, you will need it to create widget zones or to create a theme customization page in WordPress’ admin.