Using Templates in your WordPress Theme

So, you think that you want to use WordPress to run your church website and you have heard that in WordPress you can customize your website’s theme through the use of templates.  But what ever are templates?

To explain this it is helpful to understand how WordPress works in the background when someone visits your website.  First off WordPress makes a determination as to what it is that each visitor is looking for.  For example, "Has the visitor requested the home page?  Has the visitor requested a particular item (i.e. a specific page or post, a category, an author, a tag etc.)?  Has the visitor done a search and is asking for the results?  Once this is determined WordPress then fetches that information from the database and and displays it based on the WordPress "theme" that you are using. In order to display all the bits of information that make up a typical web page WordPress gathers the information through a series components called "templates" and ties them together into a comprehensive whole.1

Each of these templates will likely handle only the information for a particular section of a web page or a particular type of content to be displayed. These web page sections might be the top of the page, commonly known as the header, the middle section which carries all the "blog" or "page" information, commonly known as the body, or the bottom of the page which might have copyright information or links to contact you etc., commonly known as the footer. Each of these sections might have other sections within them. For example the body section might have a right and left sidebar, the header might have a navigation system for the entire site. These are all likely generated through the use of templates. Each template is (usually) a separate file within the structure of the theme. For example a particular theme might have a header template file (header.php) and a footer template file (footer.php) and a sidebar template file (sidebar.php ) and a comment file (comment.php) a loop file (theloop.php) file and so on.2 Larger components (template files) might incorporate several of the smaller templates in a single file. This would be the case with a category template file (category.php) or an author template file (author.php).

There are several primary components (files) that make up a theme.  You can view a graphical representation of how these files are targeted when someone comes to your site.  I find this very helpful when designing a theme and deciding how I want the flow of information to progress on the website:

  • index.php – this is the ultimate default file that WordPress loads.  If no other component file fits what the visitor is asking for – this file displays.
  • home.php – this is the first file that WordPress looks for when the visitor makes that first inquiry or when he clicks on your "Home" link.
  • archive.php – this is the default file that WordPress loads when some older content is requested.
  • page.php – this is the file that WordPress loads when an individual "page" is requested.
  • single.php – this is the file that WordPress loads when an individual "post" is requested.
  • 404.php – this is the file that WordPress loads when the content that the visitor is requesting cannot be located in the database.
  • various other specialty template files for specific uses – i.e. targeting an individual category using category.php or an individual author using author.php etc.  You can find more information on templates here.

Each of these primary components (files) incorporate the various template files within them to draw the information from the database and present it on the page.  So a typical "home.php" file will incorporate a call to the header.php file, the WordPress loop, the sidebar.php file and the footer.php file.  It will display the resulting information and style it using the CSS file that is also a part of every theme.  All of these files can be shaped the way you want them to meet the needs of your particular theme.  If you are new to WordPress take a look at the default themes that comes packaged with WordPress and familiarize yourself with the way these various files are laid out.  They can be found under "wp-content >themes".

WordPress has several built-in functions – get_header() - get_footer() - get_sidebar() – that will load the more common templates.  Custom templates3 can be included in the code by using the php "include" function – i.e. <?php include (TEMPLATEPATH . '/my_custom_footer.php'); ?>.

When designing a church website these are helpful factors to keep in mind.


  • 1WordPress comes with a couple of default themes for you to choose from but there are thousands of others out there on the web for you to choose from should you so desire. The theme takes this dynamically generated content and displays it in the manner that you want it to.  Click here if you would like to read more on WordPress themes.
  • 2I intend to discuss the loop in another article.
  • 3I might write more on custom templates in another article.