Meet WordPress
WordPress is a content management system that runs more than forty percent of the world's sites: blogs, shops, company sites. It is not a framework in the usual sense: you do not write an application from scratch but extend a ready one — with themes and plugins.
Installation
You need PHP, MySQL or MariaDB and a web server. The steps:
- Download the archive from
wordpress.organd unpack it into the site folder. - Create an empty database.
- Open the site in a browser — the installer asks for the database details, the site title and the administrator password.
With the WP-CLI program the same is done in the terminal:
wp core download
wp config create --dbname=blog --dbuser=root --dbpass=secret
wp core install --url=blog.test --title="My blog" --admin_user=admin --admin_email=admin@example.comWhat a site consists of
| Folder or file | What is in it |
|---|---|
wp-admin | The dashboard |
wp-includes | The WordPress core |
wp-content/themes | Themes — the look of the site |
wp-content/plugins | Plugins — extra features |
wp-content/uploads | Uploaded images and files |
wp-config.php | Database connection settings and modes |
Your code lives only in wp-content. The wp-admin and wp-includes folders are never touched.
The dashboard
The dashboard opens at /wp-admin. There you create posts and pages, upload images, switch themes and enable plugins.
| Term | What it means |
|---|---|
| Post | A blog article: it has a date, categories and tags |
| Page | A standalone page without a date: "About", "Contact" |
| Category, tag | Ways to group posts |
| Media file | An uploaded image or document |
A theme and a plugin
A theme is responsible for the look: page templates, styles, scripts. A plugin adds features: a contact form, a shop, a custom post type. The rule is simple: anything that must survive a change of design is written in a plugin.
Settings in wp-config.php
// wp-config.php
define('DB_NAME', 'blog');
define('DB_USER', 'root');
define('DB_PASSWORD', 'secret');
define('DB_HOST', 'localhost');
$table_prefix = 'wp_';Debug mode
By default WordPress hides PHP errors. During development they are turned on:
// wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);Errors are written to the wp-content/debug.log file. The Query Monitor plugin shows database queries, hooks and timings right in the dashboard.
Common mistake
Never edit core files or other people's themes and plugins: the very first update erases your changes. WordPress behaviour is changed from outside — with hooks from your own theme or plugin, and someone else's theme is adjusted through a child theme. The following lessons cover that.