Encodera

Thanks for reading!

Donate to the site — we work hard for you.

Contents

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:

  1. Download the archive from wordpress.org and unpack it into the site folder.
  2. Create an empty database.
  3. 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.com

What a site consists of

Folder or fileWhat is in it
wp-adminThe dashboard
wp-includesThe WordPress core
wp-content/themesThemes — the look of the site
wp-content/pluginsPlugins — extra features
wp-content/uploadsUploaded images and files
wp-config.phpDatabase 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.

TermWhat it means
PostA blog article: it has a date, categories and tags
PageA standalone page without a date: "About", "Contact"
Category, tagWays to group posts
Media fileAn 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.

Thanks for reading!

Donate to the site — we work hard for you.