If you are a beginner web developer stepping into WordPress, you might be interested to know how it works under the hood.
This post will help you to get familiar with the programming and markup languages that power WordPress.
You already know that WordPress is a Content Management System. That means it is basically a CRUD application that allows you to create, read, update, and delete content.
For example, when you create a post in WordPress, the form data is submitted to the server where it gets processed and stored in the database.
Similarly, when you visit a post or a page, the server receives the request, processes it, retrieves the post’s data from the database, and sends the response back to the browser.
These server-side works make WordPress a dynamic system. Unlike a static HTML site, it generates pages on the go. So, we can divide the programming languages used by such a website into two:
- Server-side languages
- Client-side languages
Now, we can look into each of these in the WordPress scenario.
WordPress uses PHP on the server to do all the big jobs. Although the trend of PHP has been on the decline, it is still the most popular server-side programming language.
According to BuiltWith, PHP powers more than 37 million websites worldwide.
If you have been using WordPress, you might know that it consists of three main components:
- Core files
PHP is the language to write the majority of these files.
To get a feel of it, download the WordPress package, and extract it. Then open the folder in your favorite text editor. You can see a bunch of files with the extension .php.
When a request reaches the WordPress system, it goes through thousands of lines of PHP code before producing an HTML response that you see in the browser.
For example, suppose you have a page with the permalink yoursite.com/about/. When someone requests that page, it first reaches the index.php file in the root folder.
After that, it goes through several other files, including themes and plugins. During the process, the permalink (/about/) gets parsed, and the corresponding content is retrieved from the database.
That’s a bird’s eye view of how WordPress works. The details are a lot complex.
That’s also the reason why WordPress is often slow as it involves lots of processing and database queries. Using a caching plugin is the solution to this problem.
So, you should learn PHP if you want to develop or modify a theme or plugin.
A CMS needs a database to store all the data such as content, and user information. For that purpose, WordPress uses MySQL, which is a relational database management system.
A relational database stores information in the form of tables. Oracle is another example of such a system.
Unlike Oracle, MySQL is open-source, which makes it ideal for WordPress.
Like PHP, most web hosts support MySQL as well. So you can install WordPress on almost all hosts.
It is obvious. Any web page you see today is made up of HTML unless it is a legacy flash website.
In short, the server processes the PHP script and generates the HTML code for the browser to render.
- How does PHP generate HTML? It does not happen automatically. That’s where themes come in.
Themes contain template files where you can define the HTML structure along with the PHP script. In a template file, you can mix HTML and PHP codes. When the server executes it, all the PHP code will be converted to appropriate HTML.
That’s why you do not see any PHP script in your browser. You can verify it by right-clicking and viewing the page source.
An HTML document without any design looks bland. CSS or Cascading Style Sheets solves that problem. It is a markup language that defines the look and feel of the elements on a web page.
For example, if you want headings to be bold, you can define it with CSS.
CSS can be included inline in the HTML or as a separate file with .css extension. If it is a separate file, it should be linked from the HTML.
WordPress has standard methods to include files like CSS. You usually do it in the theme’s functions.php file.
WordPress package ships with built-in support for the JQuery library. So, if your plugin or theme requires it, you don’t have to link it separately.
With the release of version 5 last year, WordPress introduced the new Gutenberg editor, which is a lot different from the previous TinyMCE editor.
Since its use is limited to the WordPress backend alone, you may never need ReactJS while developing themes or plugins for the frontend.
Moreover, if you install extra plugins, they can also include libraries on their own.
Anyway, I hope that this post has helped you to get a basic understanding of the technologies behind WordPress.