• wpforspeed

    (@wordpressforspeed)


    I am wondering how the WordPress “outer loop” works. By outer loop, I am referring to the core pages that run when WordPress is asked to deliver semantical content. The “WordPress loop is deep inside the outer loop. My question is not about the WordPress Loop.

    When the url to a post in WordPress is called, WordPress runs once to put the post with a template, build a web page, and send the page back to the requester. From what I can see, after that process is complete, WordPress runs again, not always, but always when the requested url is for a post, to be displayed on via the single.php template.

    Example, if you go to this post on my wordpress site, the outer loop runs twice, once for the requested post, then again for this post. Here is the data, showing timestamps and comments recorded by the pages as WordPress runs. The 2nd run data is in bold:

    184016 	Burning-Bridges.org: index.php: 73.183.150.152 **start this run time to record 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184017 	Burning-Bridges.org: wp-blog-header.php: 73.183.150.152 before wp-load 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184018 	Burning-Bridges.org: wp-blog-header.php: 73.183.150.152 after wp-load before wp() 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184019 	Burning-Bridges.org: wp-blog-header.php: 73.183.150.152 before Mr. Template-Loader 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184020 	Burning-Bridges.org: template-loader.php: 73.183.150.152 before do_action 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184021 	Burning-Bridges.org: template-loader.php: 73.183.150.152 At door of mystery zone 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184022 	Burning-Bridges.org: template-loader.php: 73.183.150.152 inside mystery zone 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184023 	Burning-Bridges.org: template-loader.php: 73.183.150.152 escaped  mystery zone 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184024 	Burning-Bridges.org: template-loader.php: 73.183.150.152 about to maybe include a template 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184025 	Burning-Bridges.org: template-loader.php: 73.183.150.152 template decision made, going for template 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184026 	Burning-Bridges.org: template-loader.php: 73.183.150.152 template is: single.php 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184027 	Burning-Bridges.org: single.php: 73.183.150.152 single dot lol haha php START 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184031 	Burning-Bridges.org: single.php: 73.183.150.152 retunred from get_footer(), walk a amazing way 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184032 	Burning-Bridges.org: wp-blog-header.php: 73.183.150.152 back from Mr. Template-Loader, everyone goes home! 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    184033 	Burning-Bridges.org: index.php: 73.183.150.152 **everything done, nothing should be happening, except everyone walking away. 	/wordpress-has-an-outer-loop/ 	2014-06-22 16:45:41
    **** why doesn't WordPress stop here?  This time stamp is made at the bottom of index.php, when everything needed for the request has been run and is complete, yet the following time stamps show programs rana again.  
    
    <strong>184034 	Burning-Bridges.org: index.php: 73.183.150.152 **start this run time to record 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:41
    184035 	Burning-Bridges.org: wp-blog-header.php: 73.183.150.152 before wp-load 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:41
    184036 	Burning-Bridges.org: wp-blog-header.php: 73.183.150.152 after wp-load before wp() 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:42
    184037 	Burning-Bridges.org: wp-blog-header.php: 73.183.150.152 before Mr. Template-Loader 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:42
    184038 	Burning-Bridges.org: template-loader.php: 73.183.150.152 before do_action 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:42
    184039 	Burning-Bridges.org: template-loader.php: 73.183.150.152 At door of mystery zone 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:42
    184040 	Burning-Bridges.org: template-loader.php: 73.183.150.152 inside mystery zone 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:42
    184041 	Burning-Bridges.org: template-loader.php: 73.183.150.152 escaped  mystery zone 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:42
    184042 	Burning-Bridges.org: template-loader.php: 73.183.150.152 about to maybe include a template 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:42
    184043 	Burning-Bridges.org: template-loader.php: 73.183.150.152 template decision made, going for template 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:42
    184044 	Burning-Bridges.org: template-loader.php: 73.183.150.152 template is: single.php 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:42
    184045 	Burning-Bridges.org: single.php: 73.183.150.152 single dot lol haha php START 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:42
    184049 	Burning-Bridges.org: single.php: 73.183.150.152 retunred from get_footer(), walk a amazing way 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:42
    184050 	Burning-Bridges.org: wp-blog-header.php: 73.183.150.152 back from Mr. Template-Loader, everyone goes home! 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:42
    184051 	Burning-Bridges.org: index.php: 73.183.150.152 **everything done, nothing should be happening, except everyone walking away. 	/hit-logs-for-the-home-page-shows-outer-loop-with-no-rerun/ 	2014-06-22 16:45:42</strong>

    [Moderator Note: Please post log files between backticks or use the code button.]

Viewing 3 replies - 1 through 3 (of 3 total)
  • There is no “outer loop” in WordPress. Can you replicate the problem using the default Twenty Fourteen theme with all plugins deactivated?

    Thread Starter wpforspeed

    (@wordpressforspeed)

    Yes, the results are the same with all plugins disabled.

    When WordPress is called to display a valid url, in runs the the following php scripts multiple times:

    • index.php
    • wp-blog-header.php
    • wp-includes/template-loader.php
    • page.php or other templates

    Steps to reproduce the result:

    1. Intall WordPress
    2. modify each php script listed above, to write a recored to a database database table when the script runs

    This produces a record of those pages running multiple times for each page request.

    I am wondering how that happens and why.

    The data shows the scripts running more than once, but I haven’t found where in the code the scripts are cycling like that. The code reads like WP should stop as soon as it gets to the end of the template it is using.

    Thread Starter wpforspeed

    (@wordpressforspeed)

    I really appreciate your time looking at this. The cycling through php scripts does not happen if permalinks are set to default. When set to Post name, here is what happens.

    Browse to home page:
    WordPress Scripts Run followed by $_SERVER[“REQUEST_URI”]
    index.php /wordPressDemo/
    wp-blog-header.php /wordPressDemo/
    wp-load.php /wordPressDemo/
    template redirect: template-loader.php /wordPressDemo/
    template redirect: template-loader.php /wordPressDemo/
    page template: index.php /wordPressDemo/

    Browse to post, hit-logs-home-page: Series of scripts runs twice, changing $_SERVER[“REQUEST_URI”] while doing so.
    WordPress Scripts Run followed by $_SERVER[“REQUEST_URI”]
    index.php /wordPressDemo/hit-logs-home-page/
    wp-blog-header.php /wordPressDemo/hit-logs-home-page/
    wp-load.php /wordPressDemo/hit-logs-home-page/
    template redirect: template-loader.php /wordPressDemo/hit-logs-home-page/
    template redirect: template-loader.php /wordPressDemo/hit-logs-home-page/
    page template: single.php /wordPressDemo/hit-logs-home-page/
    index.php /wordPressDemo/hit-logs-post/
    wp-blog-header.php /wordPressDemo/hit-logs-post/
    wp-load.php /wordPressDemo/hit-logs-post/
    template redirect: template-loader.php /wordPressDemo/hit-logs-post/
    template redirect: template-loader.php /wordPressDemo/hit-logs-post/
    page template: single.php /wordPressDemo/hit-logs-post/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WordPress Outer Loop Cycles’ is closed to new replies.