Skip to content
Tutorials Center
My learning

Topics

Lesson 3 of 68 ยท Getting Started

Anatomy of a WordPress Install

Tour the WordPress file structure. Learn what wp-admin, wp-includes and wp-content hold, how index.php and wp-settings.php start a request, and which files you may edit.

Unzip WordPress and you get a surprising number of files. Knowing what each folder is for tells you where your own code belongs, what an update will overwrite, and where to look when something breaks. This lesson is a guided tour of a standard install, plus the coding conventions that WordPress developers follow.

Everything shown as WordPress files is real but read-only. The runnable examples are plain-PHP stand-ins that walk an in-memory directory layout, so you can practice reading a structure without a server.

The top-level layout

A fresh install looks roughly like this (some files are omitted):

TEXT
public_html/
โ”œโ”€โ”€ index.php
โ”œโ”€โ”€ wp-load.php
โ”œโ”€โ”€ wp-settings.php
โ”œโ”€โ”€ wp-config.php          <- yours
โ”œโ”€โ”€ wp-login.php
โ”œโ”€โ”€ wp-cron.php
โ”œโ”€โ”€ xmlrpc.php
โ”œโ”€โ”€ wp-admin/              <- core: the dashboard
โ”œโ”€โ”€ wp-includes/           <- core: the engine
โ””โ”€โ”€ wp-content/            <- yours
    โ”œโ”€โ”€ themes/
    โ”œโ”€โ”€ plugins/
    โ”œโ”€โ”€ mu-plugins/
    โ”œโ”€โ”€ uploads/
    โ””โ”€โ”€ languages/

Think of it as three zones:

Zone Folders and files Rule
Core wp-admin/, wp-includes/, and root files such as wp-load.php Never edit. Updates replace them.
Yours wp-content/ and wp-config.php Edit freely. Back them up.
Generated wp-content/uploads/, caches, .htaccess Written by WordPress. Back up uploads.

wp-admin and wp-includes

wp-admin/ contains everything behind /wp-admin/: the dashboard screens, the admin-ajax.php and admin-post.php entry points, and the admin CSS and JavaScript. wp-includes/ is the library that powers both the dashboard and the front end: the query classes, the hook system, the REST API, the database class, escaping and sanitizing functions, and the bundled JavaScript libraries.

Reading these folders is one of the best ways to learn. When a function behaves oddly, open its source in wp-includes/ and read it; the code is PHP like any other, and function names are searchable.

wp-content: where your code lives

wp-content/ is the only place where you normally add code:

  • themes/: one subfolder per theme. Only one theme is active at a time (plus its parent, if it is a child theme).
  • plugins/: one subfolder or single file per plugin. Any number can be active.
  • mu-plugins/: "must-use" plugins. Files here load automatically on every request, in alphabetical order, before regular plugins, and cannot be deactivated from the dashboard. Hosts and agencies use them for rules that must always apply.
  • uploads/: media files, organized in year/month folders by default. WordPress generates resized image copies here too.
  • languages/: translation files.

You will also sometimes see drop-ins, special files such as object-cache.php or db.php placed directly in wp-content/ that replace a core component, for example to use Redis for caching.

The boot files

Three small root files start every front-end request, and the chain is worth memorizing:

  1. index.php is the entry point for visitors. It defines a constant that tells WordPress to load the theme, then requires wp-blog-header.php.
  2. wp-load.php locates wp-config.php (in the root, or one folder above it) and loads it.
  3. wp-settings.php is the big one. It defines constants, loads the files in wp-includes/, loads must-use plugins, active plugins and the theme's functions.php, then fires the first hooks. You do not edit it, but you will meet its work in How WordPress Handles a Request.
flowchart TD
    A["index.php"] --> B["wp-blog-header.php"]
    B --> C["wp-load.php"]
    C --> D["wp-config.php"]
    D --> E["wp-settings.php"]
    E --> F["Core, mu-plugins,<br/>plugins, theme loaded"]
    F --> G["Query runs,<br/>template renders"]

Each file hands over to the next until WordPress is fully loaded and can answer the request.

Other root files are separate entry points: wp-login.php for logging in, wp-cron.php for scheduled tasks, and xmlrpc.php, an older remote-publishing interface that many sites disable.

Try it: walk a directory layout

The stand-in below stores a layout as a nested array and prints it as a tree, marking each zone. Walking nested data recursively is exactly how you would write a tool that inspects a real install.

PHP Print a WordPress-like directory tree

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

Try adding a languages folder under wp-content and watch the tree redraw.

Which files may I edit?

A quick decision rule: if it is in wp-admin or wp-includes, or is a root file other than wp-config.php, leave it alone. This stand-in applies the rule to a list of paths and also counts how many files each zone holds.

PHP Classify paths: safe to edit or not?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

Core coding standards

WordPress has its own coding standards so that code from thousands of authors looks alike. The ones you will notice immediately:

  • Tabs for indentation, not spaces.
  • Spaces inside parentheses: if ( $condition ) {, get_option( 'name' ).
  • snake_case for functions and variables, and Capitalized_Words for class names, such as WP_Query.
  • Yoda conditions in many places: if ( 'draft' === $status ).
  • Always prefix your own functions, classes and options so they cannot collide with others, for example acme_render_banner().
PHP
<?php
function acme_greeting( $name ) {
	if ( empty( $name ) ) {
		$name = 'friend';
	}
	return 'Hello, ' . $name . '!';
}

The examples in this course use PSR-style spacing in runnable stand-ins (they are plain PHP), and WordPress style in real WordPress snippets. You can enforce the official style automatically with PHP_CodeSniffer, covered in Testing, Coding Standards and Deployment.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Where should your own themes and plugins live?

    wp-content holds themes, plugins, mu-plugins and uploads. Core folders are replaced during updates.
  2. 2. What is special about files in wp-content/mu-plugins?

    Must-use plugins are always on. They load before regular plugins, in alphabetical order.
  3. 3. Which file locates and loads wp-config.php?

    wp-load.php finds wp-config.php and loads it. wp-settings.php, required at the end of the config, then boots the rest of WordPress.
  4. 4. Why should you prefix your own function names, such as acme_render_banner()?

    All plugins and themes share one global function namespace, so a unique prefix prevents collisions.

Summary

  • Core lives in wp-admin/, wp-includes/ and most root files. Never edit it.
  • Your code lives in wp-content/ (themes, plugins, mu-plugins) plus wp-config.php; uploads/ is generated.
  • Requests flow index.php to wp-load.php to wp-config.php to wp-settings.php, which loads plugins and the theme.
  • Must-use plugins and drop-ins let hosts and teams enforce behavior site-wide.
  • Follow the WordPress coding standards and prefix everything you define.

Next up: How WordPress Handles a Request.