How to Create a WordPress Theme from Scratch

Posted by TotalDC

Do you have a WordPress website using free theme or just decided that you want a website and want it to me completely unique? Benefits of having self hosted website versus using you can find in this article . Building your own theme puts you in complete control when it comes to looks and functionality. It can take your project up to that next level. In this article I will show you how to create your own WordPress theme from scratch.

WordPress Theme Development for Beginners

Although if you are just a beginner, WordPress theme development can be a bit intimidating. And that is understandable, because it’s a big subject and it has a lot of possibilities. And let’s you looked through source code of some available theme it’s really easy to feel overwhelmed.

That’s why you have to start with very basics to get understand what makes a WordPress theme work. So let’s talk about some core concepts.

Basic Skills Required For WordPress Theme Development

Ok, good news is that you don’t need to be an expert programmer to create your own WordPress theme. For you to start, you should have a basic understanding of these languages:

Although JavaScript is widely used and essential for advanced functionality, but if you just started to learn about WordPress it’s not completely necessary (for now).

Get To Know The WordPress Template Hierarchy

What does WordPress theme consists of? Fun fact, to create WordPress theme there is only two files which you completely must have.

  • index.php – Provides a template for your theme to display content
  • style.css – Serves as the main stylesheet for your theme.

Additionally you will need following files:

  • header.php – Displays the header portion of your website on each page
  • footer.php – Displays the footer portion of your website on each page
  • functions.php – This file is needed for functionality of your theme. Including enqueued scripts and styles

Technically you could run an entire website with just these files (perhaps for simple single page website). But often you will need to customize things a bit more. That’s where the WordPress Template Hierarchy comes into play.

WordPress Theme Hierarchy

This hierarchy gives you a way to create custom templates for various types of content in WordPress. For example change how blog posts look (single.php) or add About page (page-about.php).

The custom templates can be as broad or as narrow as you want them to be. For example templates can target just a specific post types or just the home page (front-page.php).

If you want to create a responsive WordPress theme from scratch, then you need to know Template Hierarchy. To really get the idea, be sure to check the Visual Overview.


If you would look at source code of WordPress theme you be surprised how complex it looks. But WordPress theme doesn’t have to be so complicated. For example:


if ( have_posts() ) :

    while (  have_posts() ) : the_post(); 





This is how your minimalistic index.php could look. First you get header to appear, then loop through post and get them to show up on screen if there is any, then show sidebar and footer. That’s it. WordPress theme template can be super simple, but on the other hand you can make something more complex if you need to.

Tools and Techniques to Help You Create Your Own WordPress Theme

Key to learning how to create a WordPress theme from scratch is finding ways to simplify the process – especially in the beginning. Trying to take on too much too soon can lead to frustration.

Use A WordPress Starter Theme

Although best thing to do would be creating your WordPress theme completely from an empty document, but when you are learning it’s nice to have something to start from. And That’s why WordPress has starter themes. They basically are built to give your theme project a head start by taking care of the basics. They include:

Theme Templates

A starter theme will have theme templates that cover commonly-used items. For example, you’re likely to find templates for:

  • index (index.php)
  • header (header.php)
  • footer (footer.php)
  • post archives (archive.php)
  • single posts (single.php)
  • sidebar
  • search results (search.php)

Just so you know, this list can vary based on the starter theme you choose, but in general that’s the basic idea of what you can expect to find in it.

Styles And Layouts

Why use starter theme? Starter theme’s job is to save you time. That’s why CSS styles that are included will be minimal. And perhaps mobile friendly straight from the box.

They will give you a framework to personalize the look and layout as you like and need it to be. But that’s about it because the idea is to help you build from it not to burn time by deleting all those things that you don’t need.

Customize Your Starter Theme

Now that you have bear bones of what is a WordPress theme, you have to customize it. Feel free to do whatever you like or need to make it your own website. In general when you have working bones of a theme it’s really about adding scripts, styles and other functionality that you will use in your project. As I mentioned above you have to have some basic knowledge of html, CSS and PHP. To further help you here you can find many of default WordPress functions that you most definitely will be using. Good practice would be to save code snippets to GitHub for example. That way you would not need to repeatedly write same code again and again. For example if you made navigation bar that you know you definitely will be using over and over again. Now, every time you start a new project, that setup is already there for you. It’s one less item on your to-do list.

Learn how it works

If you aren’t sure how things work the best way (and how I started) is to look is to examine default (or any other theme that you like) and seeing how it works when you change something in the code. Remember to always use dev tools in your browser (F12 button). Believe me, seeing the code in action is the best way to learn.

Now Go And Create Your Own WordPress Theme

getting started with WordPress theme development is a challenge. But, by starting out with the basics, you can gradually learn the tricks of the trade. As your skills improve, you’ll find yourself better able to work with more complex implementations.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: