m (Added Japanese interlanguage link) |
m (link was 404 and leading to a site offering online betting) |
||
(One intermediate revision by one other user not shown) | |||
Line 11: | Line 11: | ||
So, here are the steps WordPress uses to decide what posts or pages to display on a page, and display them: |
So, here are the steps WordPress uses to decide what posts or pages to display on a page, and display them: |
||
− | # When a visitor first clicks on or types a URL for a page that is part of your blog, WordPress starts by running a few core files (<tt>wp-config.php</tt>, <tt>wp-settings.php</tt>, etc.) If you are interested in the specifics of the file loading order, start at <tt>index.php</tt> and follow the chain of files as each PHP file includes/requires additional PHP files |
+ | # When a visitor first clicks on or types a URL for a page that is part of your blog, WordPress starts by running a few core files (<tt>wp-config.php</tt>, <tt>wp-settings.php</tt>, etc.) If you are interested in the specifics of the file loading order, start at <tt>index.php</tt> and follow the chain of files as each PHP file includes/requires additional PHP files. |
# WordPress loads and initializes any plugins you have activated (calls the plugin <tt>init</tt> actions). |
# WordPress loads and initializes any plugins you have activated (calls the plugin <tt>init</tt> actions). |
||
# WordPress loads the "text domain" for internationalization, and the <tt>functions.php</tt> file from the currently active theme. |
# WordPress loads the "text domain" for internationalization, and the <tt>functions.php</tt> file from the currently active theme. |
||
Line 30: | Line 30: | ||
# Strips the GET variable section out of the URL (i.e. anything after a "?" in the URL). Also strips out the blog's home URL. |
# Strips the GET variable section out of the URL (i.e. anything after a "?" in the URL). Also strips out the blog's home URL. |
||
# Obtains the '''rewrite rules''' that are currently in effect, by calling <tt>$wp_rewrite->wp_rewrite_rules()</tt> (<tt>$wp_rewrite</tt> is an object of class <tt>WP_Rewrite</tt>, which is defined in <tt>wp-includes/rewrite.php</tt>). The rewrite rules are basically a set of pattern matching rules for WordPress permalinks, with a specification of what to do if the pattern matches. For instance, by default there is a rule that would match a stripped permalink like <tt>category/abc</tt>, and its specification says that it means the "abc" category was requested. There is also a rewrite rule for the home page (nothing after the blog URL). |
# Obtains the '''rewrite rules''' that are currently in effect, by calling <tt>$wp_rewrite->wp_rewrite_rules()</tt> (<tt>$wp_rewrite</tt> is an object of class <tt>WP_Rewrite</tt>, which is defined in <tt>wp-includes/rewrite.php</tt>). The rewrite rules are basically a set of pattern matching rules for WordPress permalinks, with a specification of what to do if the pattern matches. For instance, by default there is a rule that would match a stripped permalink like <tt>category/abc</tt>, and its specification says that it means the "abc" category was requested. There is also a rewrite rule for the home page (nothing after the blog URL). |
||
− | # Goes through the rewrite rules in order, until it finds a match between a rewrite rule and the |
+ | # Goes through the rewrite rules in order, until it finds a match between a rewrite rule and the URL. If nothing is found, it's a 404 error. If a match is found, WordPress extracts the information according to the rule specification. |
# Obtains the list of '''query variables''' that is currently in effect. For each query variable, WordPress checks to see if it has been set by permalink parsing, POST submission, or GET submission, and if so, WordPress saves the variable's value into the '''query specification''' array (<tt>$wp->query_vars</tt>, part of class <tt>WP</tt> in <tt>wp-includes/class-wp.php</tt>). |
# Obtains the list of '''query variables''' that is currently in effect. For each query variable, WordPress checks to see if it has been set by permalink parsing, POST submission, or GET submission, and if so, WordPress saves the variable's value into the '''query specification''' array (<tt>$wp->query_vars</tt>, part of class <tt>WP</tt> in <tt>wp-includes/class-wp.php</tt>). |
||
Languages: English • Italiano • 日本語 (Add your language)
This article is an overview for developers of the process WordPress uses to build your blog pages, and how plugins can modify that process. It is aimed at developers of plugins that will do advanced queries and permalinks, and also at developers who want to understand WordPress better, in order to add new features to the core of WordPress or fix WordPress bugs.
For more details, you'll need to read the WordPress core PHP files and functions mentioned.
So, here are the steps WordPress uses to decide what posts or pages to display on a page, and display them:
As mentioned above, WP->parse_request() (part of class WP in wp-includes/class-wp.php) parses a URL into a query specification. Here is a summary of the steps it uses to do this:
Here is an overview of the things a plugin can do to modify the default query and permalink behavior described above. Many of these modifications are described (with examples) in the article Custom Queries.