Skip to content

PHP Tutorial PHP for WordPress Developers

How WordPress Uses PHP

Lesson 326 of 369 3 min read By Deepak Paswan Updated Oct 5, 2026

WordPress is a large PHP application. Every page you see on a WordPress site is built by PHP code running on the server, using the same ideas you have learned in this course: functions, arrays, classes, sessions and cookies, and a database.

The three parts

PartWhat it isWhere
CoreThe WordPress software itselfwp-admin/, wp-includes/, root files
ThemesPHP templates and styles that decide how the site lookswp-content/themes/
PluginsPHP code that adds featureswp-content/plugins/

You never edit core. You extend WordPress with themes and plugins, using hooks (see WordPress Hooks).

What happens on a request

  1. The web server receives a request and, through rewrite rules, sends it to index.php.
  2. index.php loads wp-blog-header.php, which loads wp-load.php and wp-config.php.
  3. wp-config.php defines the database settings and constants.
  4. WordPress connects to MySQL, loads active plugins, then the theme’s functions.php.
  5. It runs init and other hooks, parses the URL and decides what content was asked for (a post, a page, an archive, a search).
  6. It runs a query and chooses a template from your theme.
  7. The template prints HTML using functions such as the_title() and the_content().
  8. PHP sends the page to the browser.

It is the same flow as How PHP Works, with a lot of machinery in the middle.

The WordPress style of PHP

WordPress began in 2003 and is backwards compatible, so its style looks different from modern frameworks:

  • Many global functions with a wp_ prefix or a plugin prefix (wp_enqueue_script, get_option).
  • Global variables such as $post and $wpdb.
  • Hooks (actions and filters) as the main extension mechanism.
  • Its own coding standards: tabs for indentation, snake_case names, spaces inside brackets.
  • Classes exist (WP_Query, WP_Post, WP_User) and are used more and more.

Modern plugin code can still use namespaces, typed classes and Composer inside a plugin.

Checking that WordPress is running

index.php
PHP
<?php
echo defined("ABSPATH") ? "WordPress is loaded\n" : "not loaded\n";
echo function_exists("add_action") ? "hooks are available\n" : "no hooks\n";
echo is_string(get_bloginfo("name")) ? "site name is a string" : "unexpected";
Output
OUTPUT
WordPress is loaded
hooks are available
site name is a string

(That example was run inside a real WordPress installation.)

Version and requirements

WordPress needs a minimum PHP version, and recommends newer ones. Requirements change with each release, so check the official page before choosing a host: wordpress.org/about/requirements. Running a supported PHP version matters for security (see PHP Versions).

index.php
PHP
<?php
echo is_string(wp_get_wp_version()) ? "WordPress " . (version_compare(wp_get_wp_version(), "6.0", ">=") ? "6.0 or newer" : "older than 6.0") : "";
Output
OUTPUT
WordPress 6.0 or newer

What PHP skills carry over

This courseIn WordPress
FunctionsTemplate tags, hook callbacks
ArraysSettings, query arguments, post meta
Include and requireTheme parts, plugin files
OOPWP_Query, widgets, modern plugin architecture
SecurityEscaping, nonces, $wpdb->prepare()
Sessions and cookiesWordPress uses its own login cookies
info
This chapter is about PHP
It is not a full WordPress course. It shows the PHP side of themes and plugins, so that you can read and write WordPress code with confidence.