#49496 closed enhancement (duplicate)
filters missing for get_header and get_footer
Reported by: | kevdotbadger | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.4 |
Component: | Themes | Keywords: | has-patch |
Focuses: | template | Cc: |
Description
Seems like a minor thing that has quite a big impact. The preferred way to load different headers and footers is to use the $name argument in get_header() and get_footer().
This works fine. However, modifying them from a plugin, or even from a theme when logic decides which is loaded makes them get messy quite quickly.
A solution (which I've used), is to set the $name argument to a 'global' variable in my functions.php file and then use that thoughout my theme. When I need to conditionally set the header/footer I simply update that variable.
Surely a filter for both get_header() and get_footer(), would be a better solution?
Attachments (2)
Change History (5)
#1
@
5 years ago
- Keywords has-patch added
I've just added a patch which adds the functionality, but could do with looking over.
The get_header() and get_footer() functions seems to work as arrays, and uses the first item in the array as the actual file to load. I guess the others are fallbacks? So, using the filter will require you to add your additional template as the first item (using array_unshift).
Could possibly rewrite this, and do that inside the actual get_header (or get_header)?
patch to add update_header_template and update_footer_template