To an editor, WordPress is a dashboard for writing pages. To a developer, it is a PHP application with a database, a templating system and a large set of APIs you can extend without touching its own code. This lesson gives you the map you will use for the rest of the course.
You already know PHP from PHP for Beginners. WordPress is written in the same PHP: functions, arrays, include and require. What is new is the structure around it and the rules for where your code lives.
The five parts
Every WordPress site is made of the same pieces:
| Part | What it is | Who changes it |
|---|---|---|
| Core | The PHP files that ship with WordPress: routing, users, posts, the admin screens, the APIs | The WordPress project, through updates |
| Database | A MySQL or MariaDB database holding posts, users, settings and metadata | WordPress and your code, through APIs |
| Themes | Control how the site looks: templates, styles, layout | You or a theme author |
| Plugins | Add or change behaviour: post types, integrations, forms, REST endpoints | You or a plugin author |
| The block editor | The JavaScript editing interface, also called Gutenberg, used for content and, in block themes, for whole site layouts | WordPress core, extended by blocks |
On top of these sits the content itself: posts, pages, media and users, all stored in the database.
Core: the part you never edit
Core is everything in the wp-admin and wp-includes folders plus the PHP files in the site root. It loads the configuration, connects to the database, works out which content the visitor asked for, and hands over to the theme to render it.
You will read core code often. It is the best documentation of how a function really behaves. But you never change it. Every update replaces those files, so any edit is lost, and a modified core is a security and support problem.
If a tutorial tells you to edit a file in wp-includes or wp-admin, find another way. WordPress almost always offers a hook or an API for the change you want.
Hooks: how you change core without editing it
Core is full of named points where it pauses and lets other code run. These are hooks. There are two kinds:
- Actions let you run code at a moment, such as "WordPress has finished loading" or "a post was saved".
- Filters let you change a value before WordPress uses it, such as the title of a post or the text of an email.
Themes and plugins attach their own functions to these hooks. This is the single most important idea in WordPress development, and you will learn it properly in the hooks lessons. For now, remember that nearly all custom code is a function attached to a hook.
Themes: presentation
A theme decides what visitors see. There are two styles of theme in use today:
- Classic themes use PHP template files such as
index.php,single.phpandarchive.php, plus afunctions.phpfile. - Block themes use HTML template files made of blocks, a
theme.jsonfile for settings and styles, and the Site Editor so users can change layouts visually.
Both styles still use the same core underneath. A separate Block Theme Development course covers block themes in depth. This course focuses on the PHP layer that all themes share.
Plugins: behaviour
A plugin is a folder in wp-content/plugins with at least one PHP file that has a header comment. Plugins add features: custom content types, settings screens, integrations with other services, REST API endpoints, scheduled tasks.
The rule of thumb is simple. If a feature should keep working after the site changes its theme, it belongs in a plugin. The lesson on themes versus plugins covers this decision in detail.
The database
WordPress stores almost everything in a handful of tables:
- Posts hold posts, pages, attachments, menu items and any custom content type.
- Post meta holds extra fields for each post.
- Terms and taxonomies hold categories, tags and your own groupings.
- Users and user meta hold accounts and their settings.
- Options hold site-wide settings.
You rarely write SQL. WordPress gives you functions such as get_posts(), get_post_meta() and get_option() that read and write these tables safely and use caching.
The block editor
The block editor is a JavaScript application, built with React, that talks to WordPress through the REST API. Editors build content from blocks such as paragraphs, images and columns. When a post is saved, the blocks are stored as HTML with comment markers inside the post content.
As a PHP developer you meet the editor in three places: registering post types that appear in it, exposing data through the REST API, and registering blocks. Building custom blocks is covered in the Custom Gutenberg Block Development course.
Where your code goes
Here is the map you will use when deciding where something belongs:
| You want to | Put it in |
|---|---|
| Change colours, layout or templates | The theme (or a child theme) |
| Add a content type, shortcode, REST endpoint or integration | A plugin |
| Force code to run on every request, for example on a client site that must not be switched off | A must-use plugin in wp-content/mu-plugins |
| Change database, debug or environment settings | wp-config.php |
| Change how core behaves | A hook, from a plugin or theme |
Prefix everything you write. WordPress runs every plugin and theme in the same PHP process, so a function called get_books() will collide with somebody else's. This course uses myplugin_ and mytheme_ as prefixes.
The project you will build
Through this course you will build a small plugin for an events site. It registers its own content types and taxonomies, queries them efficiently, exposes them through custom REST endpoints, protects every form and request, and caches expensive work. Each lesson adds one piece.
Summary
- WordPress is a PHP application: core, a database, themes, plugins and the block editor.
- Never edit core. Change its behaviour through hooks.
- Actions run code at a moment; filters change a value.
- Themes handle presentation; plugins handle behaviour that must survive a theme change.
- Read and write data through WordPress functions rather than raw SQL.
- Prefix every function, hook and option you create.
In the next lesson you will set up a local WordPress site to work on.