In this guide, we have covered all the details of the internal functions within WordPress.
We all use and love WordPress for many reasons. It’s accessible, customizable, and user-friendly, allowing anyone to develop a website without coding knowledge. Most of us have used the Content Management System for years without worrying about its internal functions.
It may seem like something you should not bother with learning today.
But do you know that some common WordPress problems cannot be resolved without digging into the database? Many of you may have faced the same situation when you had to take external help for technical issues. Being aware of the internal functions may have saved you from the hassle of contacting a professional.
Knowing the internal processes will help you manage the website more efficiently. It will also enable you to troubleshoot some common WordPress errors without relying on others.
This guide aims to help you with just that. Here, you will learn about:
- The files are part of the internal structure of WordPress
- The database
- How WordPress retrieves data for the user
- The files that you should backup
So, without further ado, let’s get behind the scenes and find out how WordPress works.
The WordPress Internal Structure
When you launch a WordPress website, two things happen: 1) A bunch of files are installed on your site, and 2) the system creates a database.
You can access both of these files through the account provided by your hosting provider. To access the files installed on your site, log in to the web host and go to a page called cPanel.
From there, you can choose the File Manager option, which will give you an inside look at the files installed on your site.
To access the database, choose the Database Management Software, such as phpMyAdmin, from the cPanel. This will open up the table where WordPress stores all your posts and pages.
WordPress Files
When you enter the File Manager page, you will see many files and folders used to build a WordPress site.
However, the most important ones are:
- wp-admin
- wp-content
- wp-includes
These can be found in the “public_html” file inside the File Manager. But remember that modifying any part of these pages can break your site. So don’t attempt any DIY without knowing what you are doing.
wp-admin
As the name suggests, wp-admin contains the files that power the Admin dashboard. This file gives you access to the admin page and performs functions like writing posts, moderating comments, verifying themes and plugins, etc.
Furthermore, this area also checks if the credentials you have provided are correct and whether you are the admin or someone with limited ability to contribute to the webpage.
wp-content
The wp-content file contains three subfolders on a fresh WordPress installation: Themes, Plugins, and Uploads.
Whenever you install a theme, it’s stored in the Themes folder, and the plugins are inside the Plugins folder. The images you upload through the Media Library are stored in the Uploads folder.
wp-includes
The files in the wp-includes are responsible for how the WordPress site looks and functions with other features. From the text’s font to the widgets and caches – the wp-includes has all the core files for WordPress.
The files also contain rules, hierarchies, and action commands for some WordPress features.
Again, you don’t want to modify any files in this directory.
The .htaccess and wp-config.php files
In addition to the core files, you will find .htaccess and wp-config.php, which are part of every WordPress installation. They are also part of the public_html folder.
.htaccess
Short for hypertext access, it controls access to all your files and folders. Most importantly, it manages how your site displays the permalinks. When you change the permalink structure, the .htaccess file is updated with new instructions for the server.
You can also use the .htaccess to alter the security settings of your website and manage the redirects.
wp-config.php
The wp-config.php file mediates between your WordPress site and the database. It contains all the WordPress settings that help establish a reliable connection.
Without the information, your website will not work and show the ‘error establishing database connection‘ error.
The wp-config-php can edit your website’s database settings, tweak your memory limit, and even turn on WordPress auto-updates. However, this is a critical file, and we recommend that you don’t modify it without proper knowledge.
Database:
The database is a storage shelf for all your posts, pages, and comments. By default, you will see only twelve tables in the database. However, the tables will also increase as you expand your site and add more content.
Database tables have a default prefix wp_, which can be changed at will. You can also optimize and repair them as required. But don’t forget to back up your website so you can quickly restore it if anything goes wrong.
Here is a breakdown of the tables that are part of the WordPress database.
Table 1: wp_commentmeta
This table stores the metadata for comments left on your WordPress site. It stores information like whether a comment is approved, pending, or discarded.
Table 2: wp_comments
The wp_comments table contains unique information about each comment left on your website. For example, this table includes the author’s email address, IP address, time of messaging, etc.
Table 3: wp_links
This takes care of the blogrolls or a list of hyperlinks to other blogs or websites created in previous versions of WordPress.
Table 4: wp_options
The wp_options store data related to the Settings feature, accessible through the main dashboard. Any changes you make to the site title, tagline, URL, etc., through the settings are stored in the wp_options table.
Table 5: wp_postmeta
This table contains the Meta information about your posts, pages, and custom posts. Each file in this table includes a unique identification number that helps locate the posts and web pages when required.
Table 6: wp_posts
As the name suggests, this table stores information from posts, pages, and the navigation menu.
Table 7: wp_termmeta
Term meta allows developers to store custom data about terms in a standard way. For example, an online store can store the metadata for specific products and categories through the specified table.
Table 8: wp_terms
wp_terms stores three things: categories for tags of posts, categories of posts, and link categories.
Table 9: wp_term_relationships
This table stores relationship data for categories and tags from the wp_terms table. For example, you have a post titled A in category 7. The wp_term_relationship will determine that A belongs in the seven category and none other.
Table 10: wp_term_taxonomy
This table defines the taxonomies (links, tags, and categories) for terms in the wp_terms table.
Table 11: wp_usermeta
The wp_usermeta contains Meta information about the registered users on your website.
Table 12: wp_users
This database contains user information, such as your WordPress website’s usernames, passwords, and email addresses.
How WordPress Responds to a User’s Request?
For an average user, asking to open a website merely requires entering the specified URL and automatically loading the web page onto their screen.
But the internal functions are much more than that.
WordPress dynamically generates an HTML code to serve the user when someone requests to view your webpage. The steps that are followed are outlined below.
- WordPress calls the required PHP script.
- The WordPress core communicates with the database to acquire the relevant posts and pages.
- It combines the data with the plugin and theme information to ‘dynamically’ generate the HTML code for the visitor.
Similarly, when a post receives a comment or other interaction, the WordPress internal functions save them in the database for future use. It also notifies the administrator regarding the pending number of comments via the main dashboard.
Do I Need to back up?
Yes, definitely! Data loss is a normal part of a website’s functioning on the World Wide Web. It can occur due to many factors, including programming malfunctions, hacks, plugin and theme errors, and natural disasters.
Regardless of the reason, you must regularly back up specific files on your website to ensure you can retrieve them in case of a data loss. These files include:
- Core WordPress files (found in public_html file)
- Files that contain information about your posts, plugins, themes,
- WordPress configuration files
- Your WordPress Database
Final Words
With that, we have covered the basics you need to know about the database and the WordPress file structure. Beyond curiosity, you must know about these files to avoid accidental modification and manage your website more effectively.