Герб Укріїни
Believe in Ukraine and the Armed Forces. Glory to Ukraine!

File structure (theme, template, folders) WordPress

Article updated in November 2026.



You can find many ready-made themes for a WordPress site, both free and paid. You can choose the design, parameters and functionality that suit your project. Each theme can also be customized: in the admin panel you can change the logo, site title, description, fonts, colors, background and other settings.

Sometimes you need to change a detail that the admin panel has no tool for. Then you have to look inside the theme. It is a folder of files, and each file is responsible for one part of the site. To read and edit them, you need basic HTML (markup), CSS (styles) and a little PHP.

Even with minimal knowledge, you can adapt a theme to your needs. That is what a theme is for: it gives a standard site its own look.

Classic themes and block themes

Today WordPress has two kinds of themes, and their file structure differs:

  • Classic themes are built from PHP template files (header.php, single.php and so on). Most themes created before 2022 are classic, and many are still in use.
  • Block themes are built from HTML templates made of blocks, plus a theme.json settings file. You edit them visually in Appearance → Editor (the Site Editor), without touching code.

Check which kind you have before editing. If your admin menu has Appearance → Editor rather than Customize, you most likely have a block theme.

WordPress file structure (classic theme)

A classic theme lives in wp-content/themes/your-theme/. These are the main files:

  • index.php — the only template a classic theme must have, along with style.css. It is the fallback: WordPress uses it whenever no more specific template exists. The homepage uses it unless front-page.php or home.php exists.
  • header.php — the top of the site (the header). It usually contains the <head> section, the logo and the menu, and it is loaded with get_header().
  • footer.php — the bottom of the site (the footer, also called the “basement”), loaded with get_footer().
  • page.php — displays standard WordPress pages.
  • single.php — displays a single post.
  • sidebar.php — the sidebar, on the left or right, loaded with get_sidebar().
  • comments.php — the comments template, loaded with comments_template().
  • archive.php — the general archive template. Category, tag, author and date archives fall back to it if they have no template of their own.
  • functions.php — the theme’s functions file. It registers menus, sidebars and images sizes, loads styles and scripts (with wp_enqueue_scripts), and adds or removes features.
  • category.php — displays category archives with short post excerpts.
  • author.php — displays the posts of a specific author.
  • style.css — the main stylesheet. The comment block at the top is required: WordPress reads the theme name, description, version and author from it, and without at least a Theme Name line it will not recognize the theme. You can rename the theme and change the description there.
  • searchform.php — the search form template, used by get_search_form().
  • 404.php — shown when a visitor opens a non-existent address. You can read more in our article How to edit the 404 page in WordPress.
  • tag.php — displays tag archives.
  • search.php — the search results page.
  • attachment.php — displays attachment pages for uploaded files.

Other files are optional but common: front-page.php (the static front page), home.php (the blog posts page), singular.php, taxonomy.php, screenshot.png (the preview in the theme list) and a template-parts/ folder with reusable fragments loaded via get_template_part().

Block theme structure

A block theme replaces most PHP files with HTML templates:

  • style.css — still required, mainly for the theme header.
  • theme.json — global settings and styles: color palette, typography, spacing and layout.
  • templates/ — page templates such as index.html (required), single.html, page.html, archive.html and 404.html.
  • parts/ — reusable parts such as header.html and footer.html.
  • patterns/ — ready-made block layouts.
  • styles/ — optional style variations.
  • functions.php — optional, but still used for custom code.

Where the theme sits in WordPress folders

A standard installation has three main places:

  • wp-admin/ and wp-includes/ — the WordPress core. Do not edit them, because updates overwrite your changes.
  • wp-content/themes/ — your themes. The folder name is the theme’s identifier.
  • wp-content/plugins/ and wp-content/uploads/ — plugins and your media files.

The wp-config.php file in the site root holds the database settings and is also not part of the theme.

Child themes: a safe way to edit

If you edit a downloaded theme directly, an update will erase your changes. Instead, create a child theme. It is a separate folder with its own style.css (with a Template line pointing to the parent) and functions.php. Files you copy into it override the parent’s files, and everything else is inherited. Always back up the site before editing theme files, and test changes on a staging copy.

WordPress template structure visually

Template hierarchy

For advanced users, here is the WordPress template hierarchy. It shows which file WordPress picks for each type of page, falling back to index.php (or index.html in block themes) when nothing more specific exists.



The official Template Hierarchy documentation and the interactive site wphierarchy.com show the relationships between files in more detail.

How an AI assistant can help

An assistant such as Claude can explain what a template file does if you paste its code. It can also suggest which file in the hierarchy to edit, draft a child theme’s style.css and functions.php, or review your changes for errors. Always test its suggestions on a staging copy before using them on a live site.

We hope this article on the WordPress file structure (themes, templates, folders) is useful to you. Thank you for your attention.

Tags

Leave a Reply

Your email address will not be published. Required fields are marked *