How to build your own WP theme – Part 1: The Basics

|

This is an introductory article on the topic of creating your own templates in the WordPress content management system. In this article, we will introduce this world’s most widely used content management system, discuss its strengths, and show the basic structure of the system.

WordPress is an open-source content management system (CMS) written in PHP that currently powers over 40% of all websites on the internet. It started in 2003 as a simple blogging platform, but over time evolved into a fully-fledged tool for building virtually any kind of website – from personal blogs and company portfolios to complex e-commerce stores.

There are two versions worth knowing about. WordPress.com is a hosted service where everything is set up for you, but your customization options are limited. WordPress.org, on the other hand, is the freely downloadable version you install on your own hosting server – and that’s the one we care about, because it’s the only version that gives you full control over the code and the theme.

Why is WordPress so popular?

WordPress earned its dominant position for several closely related reasons.

First, there’s ease of use. The admin interface is intuitive and managing content requires no programming knowledge. Posts, pages, media – everything can be handled through a clean dashboard without writing a single line of code.

Second is the massive ecosystem. WordPress has thousands of free and premium themes and over 60,000 plugins that extend its functionality to cover almost anything imaginable – SEO, contact forms, e-commerce, caching, security, and much more.

Third is flexibility. Thanks to its well-designed system of hooks, filters, and the template hierarchy, WordPress can be customized down to the finest detail – and that’s exactly what we’ll be doing throughout this series as we build a theme from scratch.

The fourth reason is its large community. WordPress is surrounded by a huge global community of developers, designers, and users. Answers to almost any problem can be found on forums, in the official documentation, or on Stack Overflow.

System structure

Before we start writing any code, it’s important to understand the structure of a WordPress installation. After installing WordPress on a server, you’ll see this basic directory structure:

/
├── wp-admin/          # WP admin interface (don't touch this)
├── wp-includes/       # WordPress core (don't touch this)
└── wp-content/        # Your content – this is where you work
    ├── plugins/       # Plugins
    ├── uploads/       # Uploaded media (images, files...)
    └── themes/        # Themes

The golden rule: never edit files inside wp-admin/ or wp-includes/. Those folders belong to the WordPress core, and every update will overwrite any changes you make there.

Your working space is exclusively the wp-content/ folder. Themes specifically live inside wp-content/themes/, and each theme gets its own subfolder:

wp-content/themes/
├── twentytwentyfour/   # WordPress default theme
├── my-theme/           # Your custom theme ← that's where we're headed
└── another-theme/

That’s all for today. In the next part, we’ll show you what basic files a WordPress theme must contain.