Have we ever wondered how WordPress indeed works behind a scenes? For many users, it seems elementary since we form a URL and a page loads in few seconds, though there is a lot that happens behind a scenes. In this guide, we will travel we by how WordPress indeed works behind a scenes, and we have combined an easy to follow infographic as well.
Why You Should Learn How WordPress Works?
WordPress is an open source software, that means any one can investigate a formula and write their possess apps (plugins) and templates (themes) for it.
Learning how WordPress works and what goes on behind a scenes can assistance we know what we can do with it. You can learn about improving WordPress performance and write improved formula for your possess projects.
This beam will travel we by a whole routine step by step. We will start from when a user requests a page and finish when that page is entirely loaded.
Ready? Let’s get started.
You can also follow a created educational subsequent for some-more details.
1. Load wp-config.php File
The wp-config.php is a WordPress pattern file. It sets tellurian variables for a WordPress site and contains your WordPress database information. This is a initial record WordPress loads for apparent reasons. Learn some-more about wp-config.php record and how to revise it.
2. Setup Default Constants
After loading wp-config.php file, WordPress will pierce on to set default constants. This includes information like default WordPress upload location, maximum record sizes, and other default constants set in wp-config.php file.
3. Load advanced-cache.php File
If advanced-cache.php record exists on your site, afterwards WordPress will bucket it next. This record acts as a drop-in record and is used by several popular plugins quite WordPress caching plugins. If your site is regulating this file, afterwards we will see a new intent on a plugins shade called Drop-ins.
4. Load wp-content/db.php File
WordPress allows developers to emanate their possess database condensation layers and bucket them in a db.php record placed inside a wp-content folder. It is ordinarily used by WordPress caching plugins to urge database performance. If your website has this record present, afterwards WordPress will bucket it.
5. Connect MySQL and Select Database
WordPress now have adequate information to ensue further. It will pierce on to bond to a MySQL server and name a database.
If WordPress is incompetent to bond to a database, afterwards we will see a “Error substantiating database connection” blunder and WordPress will quit right here.
If all works fine, afterwards it will pierce on to subsequent steps.
6. Load object-cache.php or wp-includes/cache.php File
WordPress will now demeanour for object-cache.php file. If it doesn’t exist, afterwards WordPress will pierce on to bucket wp-includes/cache.php file.
7. Load wp-content/sunrise.php File
If it is a multisite network, afterwards WordPress will now demeanour for sunrise.php record if it exists in a wp-content folder.
8. Load Localization Library
WordPress will now bucket l10n.php library in a wp-includes folder. This record loads WordPress localization system, loads translations, sets locales, etc. See a beam on how to use WordPress in other languages.
9. Load Multisite Plugins
If it is a multisite network, afterwards WordPress will now bucket a multisite plugins. Learn some-more about how plugins work on WordPress multisite network.
10. Do Action ‘muplugins_loaded’
The action muplugins_loaded is now run by WordPress. This movement is accessible customarily to network activated plugins on a WordPress multisite.
11. Load Active Plugins
WordPress will now bucket all active plugins on a site. It does that by looking in a active_plugins entrance in a options list of your WordPress database. This allows WordPress to omit plugins that are commissioned on your site though not activated.
12. Load pluggable.php File
The pluggable.php record contains functions that can be redefined by WordPress plugins. WordPress will now see if a functions inside this record are already tangible by another plugin. Otherwise, it will conclude those functions itself.
13. Do Action ‘plugins_loaded’
WordPress will now run a movement ‘plugins_loaded’. It allows developers to offshoot their functions to run after all active plugins have been loaded.
14. Load Rewrite Rules
WordPress will now bucket a rewrite rules. These rewrite manners assistance WordPress use SEO accessible URLs.
15. Instantiate $wp_query, $wp_rewrite, $wp
At this indicate WordPress loads a following objects:
$wp_query: The tellurian instance that binds WP_Query class. It tells WordPress what calm is requested in a standard WordPress query format.
$wp_rewrite: The tellurian instance that binds your WP_Rewrite class. It contains your rewrite manners and functions that tell WordPress that URL to use to arrangement a requested content.
$wp: The tellurian instance of a WP category that contains functions that will parse your ask and perform a categorical query.
16. Do Action ‘setup_theme’
WordPress will now pierce on to run ‘setup_theme’ action. This movement runs before your WordPress thesis is loaded.
17. Load Child Theme’s functions.php File
The functions.php record acts as plugin and is used in WordPress themes to supplement thesis specific facilities to your website. If we are regulating a child theme, afterwards WordPress will now bucket your child theme’s functions.php file.
Otherwise, it will go on and bucket your stream active theme’s functions.php file.
18. Load Parent Theme’s functions.php File
If we are regulating a child theme, afterwards WordPress will now bucket your primogenitor theme’s functions.php file.
19. Do Action ‘after_setup_theme’
This movement runs after WordPress has setup a thesis and commissioned thesis functions. It is a initial movement accessible to themes.
20. Setup Current User Object
At this point, WordPress loads a stream user object. It allows WordPress to conduct a ask in suitability with a user’s purpose and capabilities.
21. Do Action ‘init’
WordPress has so distant commissioned all a essential information it needs. Now it fires a ‘init’ action.
This movement allows developers to supplement formula that needs to be executed after WordPress has commissioned all formerly mentioned information.
22. Do Action ‘widget_init’
widget_init movement allows developers to register widgets and run formula they indispensable to run during this time.
23. Run wp()
WordPress now calls
wp() duty that is located in
wp-includes/functions.php file. It sets adult a WordPress query globals $wp, $wp_query, $wp_the_query and afterwards calls $wp-main.
24. Parse Request
Now WordPress has all a information it needs to parse a user request. It starts by checking a rewrite manners to compare a user’s request.
And afterwards runs query non-static filters, ask movement hook, and sends header request.
25. Run Query
If no calm matches a query, afterwards WordPress will set is_404 variable.
Otherwise, WordPress will go on to bucket query variables.
It will afterwards run WP_Query-get_posts().
Next, it fires DO_ACTION_REF_ARRAY ‘pre_get_posts’ movement with WP_Query object.
WordPress will now run apply_filters to purify adult query and run some final checks.
Now it fetches posts from a database and relates posts_results and the_posts filters.
The query partial ends with WordPress returning a posts.
26. Do Action ‘template_redirect’
WordPress will now run a
template_redirect action. This offshoot runs only before WordPress determines that template page to load.
27. Load Feed Template
If a requested calm is a RSS feed, afterwards WordPress loads a feed template.
28. Load Template
WordPress will now demeanour for a template record formed on WordPress template hierarchy. It afterwards loads a template that customarily contains a WordPress loop.
29. Do Action ‘shutdown’
Just before finale all PHP execution, WordPress fires a final movement called shutdown.
WordPress stops operative here. It has run a formula and generated user’s requested web page.
Amazing isn’t it? All these things occur within milliseconds. If we are regulating one of these best WordPress hosting services, afterwards ideally your page will bucket in a integrate of seconds.
We wish this essay helped we learn how WordPress works behind a scenes. You might also wish to see a step by step beam on how to boost WordPress speed and performance for beginners.
Get more stuff like this
in your inbox
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.