WordPress Templates

List of Common WordPress template files:

404.php

This template will be loaded if a Page Not Found (404) error occurs on your site. There is a default 404 template included in the WordPress default theme that will be used if your theme does not include one. This site uses the default WordPress 404 template.

A very simple example for a custom 404 page from the WordPress codex follows.


<?php get_header(); ?>
<div id="content" class="narrowcolumn">
<h2 class="center">Error 404 - Not Found</h2>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

See also: Creating an error 404 page at the WordPress Codex.

back to top

archive.php

An archive template lists posts from the archive, which will be a filtered list of posts based on date criteria, such as all posts for a year or month. Usually in an archive template, excerpts of the posts are shown along with links to the full post.

back to top

archives.php

An archive index template (archives.php) is typically used to provide a list of links to archive posts, organized by year, month, etc. It differs from archive.php which will lists archive posts based on filter criteria (such as all posts for a specific year or month).

For more information on creating an archive index, see the WordPress codex here.
back to top

author.php

You can use this template to customize the profile display for authors on your blog.

For more information on author templates, see the codex article at ‘author templates‘.
back to top

comments.php

The comments template, comments.php is usually included on individual blog post pages (single.php), and is used to control the display and listing of comments on a post.

back to top

footer.php

This file is included in your other templates and holds the markup that is common to the footer of all of your pages, typically this file closes your site’s <body> and <html> tags

back to top

header.php

This file is included in your other templates and holds the markup that is common to the top of all of your pages, such as DOCTYPE declaration, <head> tags, scripts, stylesheets, etc. Usually the opening <body> tag is included here as well.

back to top

links.php

The links page template is used to display a standalone page that lists all of your WordPress links.

back to top

index.php

Required File

This is the main page of your theme, where blog posts are listed. Additionally, the way that the WordPress template hierarchy works, many of the other template files are optional, and if they aren’t present, WordPress will default to using this template.

back to top

page.php

The page template is loaded for static content pages as opposed to blog listings or posts.

back to top

comments-popup.php

This template moves the commenting ability of your theme out of the main post page and into a popup window. This was a common feature of some early blog platforms, but is rarely used now.

back to top

single.php

The single post template, single.php holds the code for showing one blog post (as opposed to static pages) and usually would be where commenting would take place on your site.

back to top

searchform.php

Many themes include a search form, that is usually included in the sidebar or footer area of the site. You can actually get the same functionality by using the search widget, which is an excellent and easy option if you don’t need to customize the form itself.

For more information on adding custom search results to your theme, check out the codex article at ‘creating a search page‘.
back to top

search.php

The search template loops over the results of a search (from searchform.php) in much the same way as posts are looped over in your main index template.

back to top

sidebar.php

This template holds the code for your site’s sidebar content area(s). This is also one of the files where WordPress widget support is generally enabled (you will also need to add code to functions.php).

back to top

templatename.php

In addition to the standard templates, you can create your own when building a theme, but instead of using a WordPress Template Tag to include the file, you can use the PHP include() function with the TEMPLATEPATH variable to do so <?php include (TEMPLATEPATH . '/templatename.php'); ?>