WordPress

How WordPress work

City look from mountain

There are thousands webpage based on WordPress, but how WordPress works? In these post, I take you behind the scene and explain, how WordPress work, where WordPress storage all webpage data, and from where WordPress take knowledge about web page view.

Static and dynamic web pages

In the beginning, it’s worth admitting that on the internet we have generally two website types: static pages, and dynamic pages. It could be a little bit confusing because on both websites type there could be engaged elements, or the same animations, videos, forms, etc. So which pages are static, and which ones are dynamic?

The major difference lays in code. To build a static page you need only HTML, CSS, JS. These kinds of web pages will display in a web browser, in the same way, day after day. They can be changed only by web developers.

On the other hand, dynamic web pages can change depends on visitor’s behavior. To build these kinds of pages, web developers need to use server-side programing language like PHP.

PHP build a webpage from data stored on the server dynamically, which means that there is no static page build from HMTL, CSS, and JS on the server, but PHP connects data storage on the server and builds a web page from these data before the server sends it to your web browser.

How WordPress work step by step

How WordPress Work blog post image

First of all, you need to know, that WordPress is just a collection of PHP functions. Of course, it’s powerful CMS, but when you deep dive into the code, it’s just a collection of the PHP functions. So just like PHP, WordPress uses these same mechanisms. You set up which should be displayed, and when, WordPress does the rest. When the client asking the server to display your website, WordPress collects all necessary data from the server, mix it and send it to a web browser.

How do WordPress themes work?

You can ask yourself now: Ok, WordPress collects data, and display it, but where is stored information about web looks? The answer is in the theme. You probably know, that you can download ready themes in the WordPress dashboard, and after activating it, the web page starts to look beautiful. But how it’s work?

On the server side, WordPress created a folder called themes in the wp-content destination. In this folder, WordPress stored all themes. The most basic themes should have four files: index.php, header.php, footer.php, and style.css. If you will use inline CSS style, style.css is not necessary.

The index.php file is the key because it contains all information about the web page look. As I write before, WordPress is based on PHP language, and have his own function library. In these library there are function called get_header() and get_footer(). So you need to nested HTML markup into header.php to build the header section. Then in index.php, you call these sections using the get_header() function. The same situation with the footer.

The last thing, if you use external CSS style, is to load the CSS style files. In WordPress, this is not obvious. Web pages are generated dynamically, and you have no access to the head section. But in the head section, we need to put a link to CSS files. How to do that?

We have WordPress function to do these, called wp_enqueue_style(). In this function, you will declare from where you want to load your CSS styles.

How do WordPress plugins work?

Plugins in WordPress generally are pieces of JS or PHP code created to make things that aren’t available in basic WordPress configuration. WordPress has a function that allows you to add extra scripts to your page called wp_enqueue_script(). In this function, you can declare where is your script stored, and if it is connected to other files, or not. Finally, when you activated some plugin, behind the scene WordPress will add function wp_enqueue_script() to index.php, which means, that the script will be fired up when somebody opens the web page.

Where WordPress storage data

You may be interested in where WordPress storage all data. There are several databases where the information is collected. WordPress uses SQL language to create tables and communicate. I wrote a lite more about it here: How to move WordPress site to new hosting

A complex description of database structure in WordPress you can find here: https://codex.wordpress.org/Database_Description

But you may also know, where are stored the most common information, so here is the list of these tables:

  • wp_commentmeta: comments metadates;
  • wp_comments: comments contents;
  • wp_links: added links and their information;
  • wp_options: web options;
  • wp_postmeta: post metadates;
  • wp_terms: categories and tags;
  • wp_term_relationships: connected categories and tags with posts;
  • wp_term_taxonomy: categories and tags descriptions;
  • wp_usermeta: users metadates ;
  • wp_users: users.

Where WordPress storage image

There is one more question about WordPress databases: where WordPress stored images? There is no way, to store images in SQL databases, which complicated system, but not so much. In databases, WordPress stored links to images, but all images that you upload to the server via WordPress dashboard are stored in /wp-content/uploads location. WordPress generates in this location another folder named form years and months, but this is just for neatness purposes.

How WordPress work – summary

In this post, I show you how WordPress works behind the scene. Of course, it is just short view in these case, but knowing that help you better understand what’s going on when you use dashboard, and help you search for trouble reason when their appear.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

X