• I’m trying to get my head around the basic WP flow, from the URL I type in the browser (either as a query string or permalink-based structure) being processed by the HTTP server to what WP displays on the page.

    I’ve traced through the blog index.php and see it calls wp-blog-header.php. This in turn “sometimes” loads/runs the wp-load.php, wp() and template-loader.php….

    if ( !isset($wp_did_header) ) {
            $wp_did_header = true;
            require_once( dirname(__FILE__) . '/wp-load.php' );
            wp();
            require_once( ABSPATH . WPINC . '/template-loader.php' );
    }
    ?>

    I’ve been through the various files and can see them processing the query string and setting up WP_Query, and various settings and cookies, and loading the theme templates etc. etc. etc.

    I have a few questions I’m hoping someone can help me with…

    First, the code above checks for wp_did_header, and if it’s not set it runs the code in the if statement, setting it as the first step. Where is this variable held, and was causes it to be unset? Is it for a user session from the browser into this blog; i.e. when you first access one of the blog pages, and then it remains until you close your browser session?

    Second, how does WP build the WP_Query on subsequent URL’s. For example, I come into my blog front page and WP goes and loads it’s stuff and builds the WP_Query. I then click on a post and go to another page in the blog. How does WP process the URL and build me the new page? The if statement above implies that it doesn’t do the wp-load.php, wp() and template-loader.php processing again.

    Finally, which common files are accessed on each page build in WP? I saw a mention somewhere that wp-config.php is read each time.

    If anyone can help or point me to some online docs on this I’d appreciate it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • very interesting question!

    I am also very confused with the WP overflow.

    Thread Starter davidedw

    (@davidedw)

    I’ve had some success with answering these questions, through good old fashioned tracing (use of the error_log() function at strategic points of the code) and a Codex article “Query Overview”.

    In response to my questions above:
    First – I can’t find where it’s unset, but the loop of wp-load.php, wp() and template-loader.php is run every time a URL is entered.

    Second – The query is processed in the parse_request() function in classes.php. The various parts of the URL and/or query string are split up and placed in the various wp_query attributes.

    Finally – it seems all paths are followed. I’m assuming that not every file is read from disk each time, but the same code paths are followed on each URL.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Understanding WordPress Flow – from URL to page’ is closed to new replies.