So you want to create your own theme on WordPress but don’t know where to start? Well here is a quick blog post to tell you exactly what is required when starting a blank WordPress theme. When creating a bespoke website, you usually need to create a blank theme in order to get your templates started.
So What Files Do I Need?
There a three files that are essential when creating your theme, they are functions.php, index.php and styles.css. The functions.php and index.php are always in the theme route but it is important that styles.css is in the route, I will explain what needs to be in each file later on in the post. It is also nice to have a screenshot.png file, which gives your theme an identity and makes it easy to differentiate between your theme and others. This should also be in the route of your theme.
In your functions.php there should be all of the functions that your website requires. This includes enqueuing your css and js files, rather than adding these to the head.
Index.php is exactly what it says, it is the index of your website. this is the front and is a minimum requirement of a wordpress website. This page can be as extensive or as minimal as you want. Once you start to develop your site, you may not be using index.php to display any information, but you should still leave it in your theme.
It is vitally important to have a styles.css in your theme as this is what determines your templates. If you do not include a styles.css in your theme, even if you add new template files, the templates will not show in your page options. The name in the commented code at the top of the styles.css determines the name of your theme and you should have commented out code at the top of the theme that looks something like this:
Theme Name: Your theme
Author: John Doe
Description: This is the theme description
Text Domain: your-theme
As previously stated, the ‘Theme Name’ code sets the name of your overall theme.
The files listed are just the core files, you may need to add other files such as:
- sidebar.php- this is the code for the sidebar of each page.
- front-page.php- this is where the index will be overwritten. If you set a static homepage, then it will use front-page.php.
- page.php- this is the code for the other pages of your website (if not using custom templates)
I hope this helps and if you have any questions, please leave a comment and we will respond.