[wp-trac] [WordPress Trac] #37302: get_header(), get_sidebar() and get_footer() doesn't use template_include()

WordPress Trac noreply at wordpress.org
Fri Jul 8 01:59:36 UTC 2016

#37302: get_header(), get_sidebar() and get_footer() doesn't use template_include()
 Reporter:  schoenwaldnils  |       Owner:
     Type:  enhancement     |      Status:  closed
 Priority:  normal          |   Milestone:
Component:  General         |     Version:  4.5.3
 Severity:  normal          |  Resolution:  duplicate
 Keywords:                  |     Focuses:  template
Changes (by DrewAPicture):

 * status:  new => closed
 * resolution:   => duplicate
 * milestone:  Awaiting Review =>


 Hi @schoenwaldnils, welcome to Trac!

 There's a lot of history for why including or requiring templates work the
 way they do in the WordPress template loader.

 A lot of it has to do with whether or not they should be loaded in global
 scope and introduce global variables across templates. I would really
 suggest reading up on #18265 where the `template_include` filter was
 introduced, though it's kind of the reverse situation.

 The basic gist is that files loaded via `get_header|sidebar|footer()`
 deliberately load global scope and files brought in through the template
 loader don't. In short: roping these functions into `template_include`
 would be an end-run around how template loading is intended to work within
 that scope.

 All of that said, since the ultimate goal is to have some measure of
 control over what's loading when, I'm closing this as a duplicate #13239,
 and encourage you to focus your attention there. `locate_template()` is
 the key.

Ticket URL: <https://core.trac.wordpress.org/ticket/37302#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list