In the previous part, we introduced the basic structure and strengths of WordPress. Today, we’ll follow up on that and show you the basic files that a template must contain.
What Files Does a Theme Need?
WordPress is quite lenient when it comes to recognizing themes – technically, just two files are enough for WordPress to consider a theme valid. In practice, though, every functional theme contains several more. Let’s walk through the most important ones.
Required Files
style.css is the only truly required file. It not only holds your theme’s CSS styles, but more importantly it must contain a file header – a block of comments at the very top of the file that WordPress uses to identify the theme:
/*
Theme Name: My Theme
Theme URI: https://example.com
Author: Your Name
Author URI: https://example.com
Description: A description of my custom theme
Version: 1.0.0
License: GNU General Public License v2 or later
Text Domain: my-theme
*/
WordPress uses this information to display the theme’s details in the admin area. Without this header comment, WordPress won’t recognize the theme at all.
index.php is the fallback template for all content types. If WordPress can’t find a more specific template file (for example, one for a category archive or a single post), it falls back to index.php. Without this file the theme technically exists, but the site won’t display content correctly.
Recommended Files
While not strictly required, you’ll find the following files practically indispensable.
functions.php is the heart of your theme. It acts like a theme-specific plugin – this is where you register navigation menus, widget areas, and WordPress feature support (post thumbnails, custom logo, etc.), and where you enqueue CSS and JavaScript files. It’s the place where your theme talks to WordPress.
header.php contains the shared page header code – typically the DOCTYPE declaration, the <head> tag with meta tags and stylesheet links, and the opening <header> element with your logo and navigation. It gets included in other templates via the get_header() function.
footer.php is the counterpart to header.php – it holds the closing section of the page, the site footer, and the closing HTML tags. It’s included with get_footer().
sidebar.php handles the sidebar and is loaded via get_sidebar(). It’s less common in modern themes, but still has its place in many layouts.
single.php displays an individual blog post.
page.php displays a static page.
archive.php handles listing pages – category archives, tag archives, author archives, and date-based archives.
404.php is displayed whenever a visitor navigates to a URL that doesn’t exist.
Minimal Starting Structure
For the purposes of this series, we’ll start with this structure:
wp-content/themes/my-theme/
├── style.css # Required – theme identification + styles
├── index.php # Required – fallback template
├── functions.php # Feature registration and script enqueuing
├── header.php # Page header
├── footer.php # Page footer
├── single.php # Single post view
├── page.php # Static page view
└── archive.php # Post listing pages
This structure gives us a solid foundation to build on and expand throughout the rest of the series.
What’s Coming Next?
In the next part, we’ll build the actual foundation of the theme – we’ll write style.css with the required file header, set up functions.php with basic feature registration, and put together header.php and footer.php so that the theme renders a working page in the browser for the first time.


