Custom WordPress themes can and typically are complex beasts, making it hard for WordPress developers to understand both how to work with them, how they can be cleaned up and improved, and how to use them to their advantage rather than shun them.
To help dispel some of these issues, here’s the most straightforward, least detailed guide on what you need to do to create your own custom WordPress theme.
My ultimate goal here is to provide a very short, easy to follow, no frills guide to setting up your first custom WordPress theme. It’s very beneficial to understand the bare minimum capabilities first. It’s also much less daunting. Hopefully this helps.
Bare Minimum Custom WordPress Theme Ingredients
Very little detail, by design to keep this short and sweet:
- Create a new folder in your
/wp-content/themes/directory, this will be your theme. style.csscontains a specific set of comments at the top to define the name of your theme (and other details). It also can contain the CSS for your theme; it will load automatically.screenshot.pngis what’s shown as a preview underAppearance > Themes.page.phpis the template that’s used for all the Pages you create in WordPress.front-page.phpwill be your homepage after you adjust yourSettings > Readingto use it.post.phpwill be the template used for all the Posts you create.functions.phpis where you add stuff that’s not part of a template.index.phplists your posts and is also the template used if no others exist.header.phpis the global header that starts all templates.footer.phpis the global footer that ends all templates.404.phpis what’s shown for a page not found (404 error).search.phpdisplays search results.archive.phpis a list of filtered posts used for categories, tags, dates, etc.category.phpis likearchive.php, but for listing posts in one category only.tag.phpis the same thing but for posts by tags.
Real-world Example in GitHub Public Repo
I’ve set up a basic theme demo of this that’s publicly available on GitHub:
Stylesheet Comment Format
/*
* Theme Name: Basic WP
* Description: Basic custom theme for WordPress that's easy to follow and learn from
* Author: Kevinleary.net
*/
WordPress Template Hierarchy
Once you understand the pieces that make up a theme, there is a constant, noticeable pattern you can follow to work with ANY theme. It’s called the template hierarchy, and it’s how WordPress decides which file in your theme to use for every URL on your site.

How WordPress Picks a Template
Every time a page loads, WordPress does the same three things:
- It works out what kind of page was requested: a single post, a page, a category, a search, and so on.
- It builds a list of template file names for that kind of page, ordered from most specific to most general.
- It looks in your theme folder for each file name in order and uses the first one it finds.
If a file doesn’t exist, WordPress skips it and tries the next one. If nothing matches, it uses index.php. That’s why index.php is the only template a theme is required to have.
Example: Category Archive
Say someone visits a category with the slug unicorns and the ID 4. WordPress looks for these files, in this order:
category-unicorns.phpcategory-4.phpcategory.phparchive.phpindex.php
Every other kind of page works the same way. The list starts with a file for one specific thing, moves to a file for that type of thing, and ends at index.php.
Template Order by Page Type
| Page Type | Templates WordPress Looks For |
|---|---|
| Front page | front-page.php, then home.php (latest posts) or page.php (static page), index.php |
| Blog posts index | home.php, index.php |
| Single post | single-{post-type}-{slug}.php, single-{post-type}.php, single.php, singular.php, index.php |
| Page | Custom page template, page-{slug}.php, page-{id}.php, page.php, singular.php, index.php |
| Category | category-{slug}.php, category-{id}.php, category.php, archive.php, index.php |
| Tag | tag-{slug}.php, tag-{id}.php, tag.php, archive.php, index.php |
| Custom taxonomy | taxonomy-{taxonomy}-{term}.php, taxonomy-{taxonomy}.php, taxonomy.php, archive.php, index.php |
| Custom post type archive | archive-{post_type}.php, archive.php, index.php |
| Author | author-{nicename}.php, author-{id}.php, author.php, archive.php, index.php |
| Date | date.php, archive.php, index.php |
| Search results | search.php, index.php |
| Not found | 404.php, index.php |
Front Page & Blog Index
The homepage is the one place people get confused. It depends on what you choose under Settings > Reading:
front-page.phpalways wins for the front page if it exists, whether you show your latest posts or a static page.home.phpis for the list of blog posts. It’s used on the front page when you show your latest posts, or on the page you set as your “Posts page”.page.phpis used when the front page is a static page and there’s nofront-page.php.
Custom Post Types
Custom post types follow the same pattern as posts. A post type named book uses single-book.php for one book and archive-book.php for the list of books, then falls back to single.php and archive.php.
Child Themes
If you use a child theme, a file in the child replaces the same file in the parent. The more specific file still wins though. A category.php in the child theme does not beat a category-unicorns.php in the parent.
Key Takeaways
- WordPress always goes from most specific to most general, and stops at the first file it finds.
index.phpis the fallback for everything.- You only need to create a more specific template when you want that page to look different.
- To find the file behind any page in any theme, work out the page type, then walk down its list until you hit a file that exists.
- Block themes use
.htmlfiles in place of.php, but the hierarchy is the same.
The full list, including attachments, embeds and the filters you can use to change the order, is in the official WordPress template hierarchy documentation.