Most people learn WordPress as a set of buttons: install a theme, install a page builder, install twelve plugins, and hope. It works until it does not, and then you have no model of what is happening underneath. A slow page, a white screen, a plugin conflict and a hacked site all look like mysteries when you do not know how a request becomes a web page.
This guide builds that model. It follows one visit from the browser to the server, through WordPress core, the database, your theme and plugins, and back to the screen. Then it covers the decisions that follow from it: hosting, themes and blocks, plugins, caching, security and a working routine. If you build WordPress sites from first principles, you choose tools on purpose, debug by reasoning, and avoid most of the common traps. This is a conceptual guide, not a test report, so you will not find benchmarks here, only how the pieces fit and what to do about it.
Key takeaways
- A WordPress page is built fresh on the server for each uncached request: PHP runs WordPress, which queries the database, runs your theme and plugins, and returns HTML.
- Almost every problem lives in one of five places: the host, WordPress core, the theme, a plugin, or the content and database.
- Content lives in the database, code in files. Knowing which is which makes backups, staging and migration make sense.
- Caching works by skipping most of that build. It is the biggest speed lever, and the source of many “why is my change not showing” problems.
- Security is mostly hygiene: updates, least privilege, strong authentication, backups. A good workflow protects you more than any single plugin.
What WordPress actually is
WordPress is a PHP application that stores content in a database and uses templates to turn that content into HTML. That is the entire idea. Everything else, from page builders to shops, is built on top.
It has four ingredients that you should keep separate in your head:
- Core. The WordPress software itself: the code that handles requests, users, content, the admin, the REST API and the hooks system.
- The theme. The code and templates that decide how content looks and which parts of the page appear.
- Plugins. Extra code that adds or changes behaviour: forms, SEO, shops, caching, security.
- Content and settings. Posts, pages, media, users, menus and options. These live in the database, with uploaded files on disk.
The separation is practical. When something breaks, you ask which of the four it belongs to. When you move a site, you move the files and the database. When you back up, you copy both. When you update, you update code, not content.
The journey of one request
Follow what happens when someone visits example.com/blog/my-post/. Each step is a place where things can go slow or wrong.
1. DNS and connection
The browser looks up the domain name in DNS to find the server’s address, opens a connection, and usually negotiates HTTPS. If you use a CDN or proxy, the request may hit that first. Problems here show up as “site not found”, certificate warnings or slow connections, and have nothing to do with WordPress.
2. The web server
The server software, commonly Nginx, Apache or LiteSpeed, receives the request. It decides whether the URL matches a real file, such as an image or a stylesheet, which it sends straight back, or whether to pass the request on to PHP. Pretty permalinks work because the server is configured to send unmatched URLs to WordPress’s index.php.
3. PHP starts WordPress
PHP runs index.php, which loads WordPress. Core reads wp-config.php for database credentials and settings, then loads its own files and connects to the database.
4. Plugins and the theme load
WordPress loads active plugins, then the active theme. Each can register hooks: small connection points where they add or change behaviour. Hooks come in two types: actions (do something at this moment) and filters (change this value before it is used). The hook system is the reason plugins can modify WordPress without editing its files, and also the reason two plugins can collide.
5. WordPress works out what was requested
It parses the URL against its rewrite rules and decides what the request is: a single post, a page, a category archive, the home page, a search or a 404. It builds a query for the matching content, called the main query, and runs it against the database.
6. The template is chosen and rendered
Using the result, WordPress picks a template from the theme by following the template hierarchy: for a single post, it looks for the most specific template available and falls back to more general ones, ending at index.php or, in block themes, index.html. The template runs, pulling in the content, the header, the footer, menus, widgets and anything plugins output. The result is a block of HTML.
7. The response travels back
The server sends the HTML. The browser reads it, discovers it needs CSS, JavaScript, fonts and images, and requests those too. Rendering and script execution then happen in the browser.
What this tells you
Three conclusions follow, and they explain most WordPress behaviour.
- A page is generated on demand. Without caching, every visit repeats steps 3 to 6. That is why hosting power and caching matter.
- Everything is code running in sequence. A fatal error in a plugin during step 4 can stop the whole page. That is the white screen or the “critical error” message.
- The browser does as much work as the server. Heavy front-end code can make a fast server feel slow. That is why page speed has a server side and a browser side; see the WordPress speed optimisation guide.
Hosting: where the code runs
Hosting is the computer, and the software on it, that executes the journey above. For WordPress, you need a web server, a recent PHP version and a database server, usually MySQL or MariaDB. WordPress.org publishes its current hosting requirements, so check them rather than relying on memory.
The main kinds
| Type | What it is | Trade-off |
|---|---|---|
| Shared hosting | Many sites on one server, managed by the host | Cheap and easy, but resources are shared and limits can bite |
| Managed WordPress hosting | A host tuned for WordPress, often with caching, backups and staging | Less work for you, less control, higher price per site |
| VPS or cloud server | A virtual server you or a panel configure | Flexible and powerful, with more responsibility for maintenance and security |
| Server-management platforms | A control panel that sets up and manages your own cloud server | A middle path: your own server, with a tool handling routine tasks |
The decision is about who does the maintenance. Managed hosting versus a VPS explains this trade-off, and hosting by use case matches types to situations. If you want a concrete example of a server-management platform, see our xCloud hosting guide.
What to check on any host
- The PHP version it runs, and whether you can change it. See the PHP version guide.
- Whether it provides backups, and how you restore them.
- Whether it offers staging.
- Whether it includes server-level caching and what it covers.
- Resource limits such as PHP workers, memory and storage.
- Support quality, and whether they help with WordPress problems or only with the server.
Hosting is the foundation. Plugins cannot compensate for a server that is overloaded or running ancient software.
Core: what you do not touch
WordPress core is the code you download from WordPress.org. The rule is simple: never edit core files. Updates overwrite them, and your changes vanish. Everything you want to change, you change through themes, plugins, settings and hooks.
Core gives you a stable set of building blocks:
- Content types. Posts and pages by default, with custom post types for anything else. See custom post types: plugin or code.
- Taxonomies. Categories and tags, and custom ones, for organising content.
- Users and roles. Capabilities that determine who can do what. See user roles and least privilege.
- The REST API. A way for other software to read and write your content.
- The Abilities API. A newer core API (from WordPress 6.9) that lets plugins register actions in a standard, discoverable way, relevant to AI tooling. See the Abilities API explained.
- The block editor. The modern editing and site-building system, covered below.
Keep core updated. WordPress releases security fixes, and minor releases are designed to be low-risk. How to manage updates sensibly, including when to automate them, is in the auto-updates risk guide.
The database: where content and settings live
WordPress stores almost everything except uploaded files and code in a database. Knowing the layout demystifies a lot.
The core tables
wp_postsholds posts, pages, menu items, revisions and custom post types, all as rows.wp_postmetaholds extra key-value data attached to posts, such as custom fields, and a great deal of plugin data.wp_optionsholds site settings, many plugin settings and cached values called transients.wp_usersandwp_usermetahold accounts and their data.wp_terms,wp_term_taxonomyandwp_term_relationshipshold categories, tags and how they attach to posts.wp_commentsholds comments.
The prefix wp_ can differ per site. Plugins may also add their own tables, which is common for shops, forms and logs.
Why this matters in practice
- Backups must include the database. Files alone are not a backup of your site.
- Autoloaded options are loaded on every request. A plugin that stores a lot of data there can slow every page. Core’s Site Health screen warns when this grows large.
- Revisions and transients can accumulate. Cleaning is useful but risky without a backup; see how to clean a database safely.
- Custom fields live in
wp_postmeta. Heavy meta queries can slow archives. That is why data modelling matters; see the ACF guide. - Moving domains means search and replace in the database, because URLs are stored in content and options. Use a tool that handles serialized data, such as WP-CLI’s search-replace.
Themes: how content becomes a page
A theme controls layout, typography, templates and often the design system. WordPress has two kinds of theme, and the difference shapes how you build.
Classic themes
A classic theme uses PHP template files such as single.php, page.php and header.php. Design settings live in the Customizer and theme options, and layout is driven by PHP code. Many well-known themes and page builders work this way.
Block themes
A block theme builds templates from blocks, stored as HTML files with block markup, with global styles defined in a theme.json file. You edit templates, headers and footers in the Site Editor, and styles such as colours, fonts and spacing live in one place. The benefit is consistency and less custom PHP; the trade-off is a different mental model, and some older plugins assume classic themes. The block themes guide compares options.
Child themes
If you customise a theme, do it in a child theme so updates to the parent do not overwrite your work. Block themes can also hold customisations in the database through the Site Editor, so know which edits live where when you move or back up a site.
Choosing a theme
Choose for performance, accessibility, maintenance record and fit with your editing approach, rather than a demo that looks impressive. A bloated multipurpose theme loads code for features you will never use. See the fastest WordPress themes guide for what to look for.
Blocks, patterns and builders: how you create layouts
The block editor, also called Gutenberg, treats content as a tree of blocks: paragraphs, images, columns, queries and more. Each block is stored in the post’s content with comment delimiters, and rendered to HTML. Some blocks are dynamic, meaning the server builds their output on each request, as with the Query Loop, which lists posts.
Patterns
Patterns are reusable arrangements of blocks, such as a hero section or a pricing table. You insert them as a starting point and edit them freely. Synced patterns, formerly called reusable blocks, stay linked, so editing one updates all uses. The advanced block editor guide covers patterns and the Query Loop.
Page builders
Page builders such as Elementor, Bricks and Breakdance provide visual design tools that go beyond core blocks, each with its own data format and output. They can speed up design work. They also add code, create a dependency on the builder, and make content harder to move to another system. The page builders comparison, Bricks vs Elementor and the Etch review discuss the options, and Etch is among the tools WPMusk uses.
CSS frameworks and design systems
Whatever builds your layouts, consistent spacing, colour and type scales keep a site coherent. Frameworks such as Automatic.css provide these as utility classes and variables; the Automatic.css guide explains the approach. The idea is more important than the product: decide your design tokens once.
A decision rule
If your site is mostly content, core blocks plus a good block theme are usually enough, and they keep your content portable. If you need complex layouts and interactions and you are comfortable with the dependency, a builder can be a sound choice. Decide on purpose, and expect to live with the choice for years.
Plugins: extending without breaking
A plugin is PHP code that hooks into WordPress. The WordPress.org directory lists many thousands, and commercial plugins exist outside it. Their power is also their risk, because every plugin runs with the same privileges as core.
What can go wrong
- Performance cost. Plugins add queries, scripts and styles. One careless plugin can slow every page.
- Security holes. Vulnerable plugins are a common way sites get compromised.
- Conflicts. Two plugins hooking the same thing can break each other. See the conflicts guide.
- Abandonment. A plugin that stops being updated becomes a liability.
- Lock-in. Data stored in a plugin’s own format can be hard to take elsewhere.
Rules that keep plugins under control
- Install a plugin only for a clear, written reason.
- Prefer one well-maintained plugin to three small ones, and prefer a setting or a few lines of code to a plugin where it is simple.
- Vet before installing; see how to vet a plugin.
- Delete what you do not use. See plugins you can delete.
- Test on staging before updating on production.
For starting points, the best WordPress plugins guide lists categories and options.
Caching: skipping the work
Since a normal request runs PHP and database queries, the biggest speed gains come from not doing that work repeatedly. Caching happens at several layers, and understanding them solves most “I changed it but nothing happened” confusion.
| Layer | What it stores | Where it lives |
|---|---|---|
| Browser cache | Static files such as images, CSS and JavaScript | The visitor’s device |
| CDN or edge cache | Static files, sometimes full pages | Servers near visitors |
| Page cache | Finished HTML for a URL | The server, or a plugin writing files |
| Object cache | Results of database lookups | Memory (Redis, Memcached) |
| OPcache | Compiled PHP code | PHP’s memory |
A page cache is the most dramatic: visitors get a prepared HTML file, with no PHP or database work. It is safe for pages that are the same for everyone and unsafe for personalised pages such as carts, accounts and checkout. An object cache helps dynamic pages that cannot be fully cached. Details are in the caching plugins guide and the Redis object cache guide, and a CDN is covered in the Cloudflare setup guide.
Debugging with caching in mind
When a change does not appear, work down the layers: hard-refresh the browser, purge the page cache, purge the CDN, and then check the code. Always test in a private window and while logged out, since cached pages are usually served only to logged-out visitors.
Performance in one paragraph
A fast site has a quick server response, small and well-ordered page weight, and little browser work. Measure first, fix the biggest item, and measure again, rather than installing optimisation plugins on instinct. The metrics Google calls Core Web Vitals, namely Largest Contentful Paint, Interaction to Next Paint and Cumulative Layout Shift, are a useful shared language; see the Core Web Vitals guide and the PageSpeed Insights guide.
Security basics from first principles
If WordPress is code that anyone on the internet can send requests to, security is about reducing what an attacker can reach and limiting what they can do if something goes wrong.
The realistic threats
- Vulnerable plugins and themes. The most common route in. Mitigation: update, delete the unused, vet new ones.
- Stolen or weak credentials. Mitigation: unique passwords, two-factor authentication and limited login attempts. See two-factor authentication.
- Too many privileges. A compromised admin account can do everything. Mitigation: give each person the lowest role they need.
- Poor hosting hygiene. Old PHP versions, shared accounts, weak file permissions.
- Spam and bots. Mostly a nuisance, sometimes a way in. See how to stop WordPress spam.
A minimum set of habits
- Keep core, plugins and themes updated.
- Use HTTPS everywhere.
- Use strong, unique passwords with a password manager and two-factor authentication for admins.
- Back up regularly and test restores.
- Limit roles and remove old users.
- Use a firewall at the host, CDN or plugin level.
- Know the recovery steps before you need them; see hacked site recovery.
The fuller treatment is in the WordPress security guide and the security plugins comparison. Notice that most of the list is process, not software.
A working workflow: local, staging, production
The biggest difference between hobby sites and reliable ones is process. A simple workflow prevents most disasters.
Three environments
- Local or development. A copy on your computer or a throwaway server where you build and break things.
- Staging. A near-copy of production to test updates and changes before they go live. See the staging site guide.
- Production. The live site. Change it only with a backup and a plan.
The routine
- Back up production, files and database.
- Make the change on staging. Update plugins, adjust templates, add content structures.
- Test the important paths: home, a post, search, forms, and checkout for shops.
- Promote to production in a quiet window, with a rollback plan.
- Verify on production and watch for errors.
- Record what changed.
A regular maintenance rhythm turns this into habit; the maintenance checklist lists the weekly, monthly and quarterly tasks, and for client work, the agency workflow guide extends it to QA and handover. If you move hosts, the migration guide applies the same logic: copy files, copy database, change URLs, test, switch DNS.
Version control and code
If you write custom code, put it in a child theme or a small custom plugin and keep it in version control such as Git. Do not edit code in the dashboard’s file editor on a live site; one typo can take the site down. For your own functionality, writing a small plugin is safer than adding snippets to a theme’s functions.php, because it survives a theme change.
Debugging by layer
With the model in your head, debugging becomes a process of elimination.
- Does it fail for everyone or just you? If only you, suspect caching, browser extensions or your account.
- Is it the server? Check uptime, error logs and PHP version changes.
- Is it a plugin? Deactivate plugins on staging, or switch to a default theme, to find the cause. This is the single most useful trick.
- Is it the theme? Switch to a default theme and compare.
- Is it content or the database? Check specific posts, options and recent imports.
- Turn on debugging. Setting
WP_DEBUGand logging errors to a file, on a non-public environment, shows the exact file and line behind a fatal error.
Take notes and change one thing at a time. If you use an AI assistant to help diagnose, remember that it can only be as good as the information you give it, and that connecting an agent to your site brings its own risks; see the AI agent security risks guide.
Where AI tooling fits into this model
AI tools are another way to interact with the same system. Through the REST API, the Abilities API and protocols such as MCP, an agent can read and change WordPress the way a user or a plugin does. This is not magic; it is another client with permissions. The first-principles rules still apply: give it the lowest role that works, test on staging, keep backups, and review changes. For an overview, see the complete guide to AI and MCP for WordPress.
Common mistakes
- Editing core or a parent theme directly. Updates erase it.
- Treating plugins as free. Every plugin has a cost in speed, risk and maintenance.
- Choosing a theme or builder for the demo. Look at the code weight and the maintenance record.
- No backups, or untested ones.
- Working on production. Use staging.
- Stacking caching layers without understanding them.
- Ignoring updates for a year, then updating everything at once.
- Giving everyone admin rights.
FAQ
What happens when someone visits a WordPress page?
The browser contacts your server, the web server passes the request to PHP, WordPress loads its core, plugins and theme, works out what content was requested, queries the database, picks a template and builds HTML. The server returns that HTML, and the browser loads the extra files it references. With page caching, the server can skip most of the middle steps and return a stored copy.
Where does WordPress store my content?
Posts, pages, settings, users and comments live in the database, mostly in tables such as wp_posts, wp_postmeta and wp_options. Uploaded images and files live on the server’s disk, usually in the wp-content/uploads folder. Themes and plugins are files on disk. A backup needs the database and the files.
What is the difference between a theme and a plugin?
A theme controls how the site looks and which templates build each page. A plugin adds functionality, such as forms, SEO or a shop. In practice the line blurs, because themes can add features and plugins can change appearance. A useful rule is that functionality you want to keep after changing themes belongs in a plugin.
Do I need a page builder?
No. Core blocks and a block theme can build most content sites. Page builders offer more design freedom and visual control, at the cost of extra code, a dependency and harder content portability. Choose one if the benefits justify that cost for your project.
Why is my WordPress site slow?
The cause is usually one of three things: slow server response from weak hosting or an unoptimised database, heavy pages from large images and many scripts, or a busy browser from heavy front-end code. Measure with tools like PageSpeed Insights and Query Monitor to see which one it is before changing anything.
How many plugins is too many?
There is no fixed limit. A few badly written plugins can hurt more than dozens of good ones. Judge each plugin by its necessity, quality, maintenance and effect on performance and security, and remove those that do not earn their place.
Is WordPress secure?
Core WordPress receives regular security updates. Most compromises come from outdated or vulnerable plugins and themes, weak credentials and excess privileges, rather than from core itself. Good habits reduce your risk considerably: updates, least privilege, two-factor authentication, backups and a firewall.
Should I use a staging site?
Yes, for anything beyond a hobby blog. Staging lets you test updates and changes without risking the live site. Take a backup, test on staging, then promote the change to production. Many hosts include one-click staging.
Conclusion and next steps
To build WordPress sites from first principles, hold on to one picture: a request arrives, the server runs PHP, WordPress loads core, plugins and theme, queries the database, renders a template and returns HTML, and caching shortcuts that work. From that picture come the practical rules: pick hosting that fits who does the maintenance, never edit core, choose themes and builders deliberately, keep plugins few and vetted, cache with understanding, secure with habits, and work through backup, staging and production.
Your next step: draw the five layers (host, core, theme, plugins, content) for a site you manage, and write what you know about each one: versions, owners, backups, risks. Gaps in that sheet are your to-do list. Then continue with speed optimisation, security and maintenance to turn the model into routine.
Let your AI assistant do this for you
Open the ready prompt with step‑by‑step instructions for running it through NibWP.