Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#49496 closed enhancement (duplicate)

filters missing for get_header and get_footer

Reported by: kevdotbadger Owned by:
Priority: normal Milestone:
Component: Themes Version: 5.4
Severity: normal Keywords: has-patch
Cc: Focuses: template

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)

49496.diff (643 bytes ) - added by kevdotbadger 7 years ago.
patch to add update_header_template and update_footer_template
49496.2.diff (770 bytes ) - added by sebastienserre 7 years ago.

Download all attachments as: .zip

Change History (5)

@kevdotbadger
7 years ago

patch to add update_header_template and update_footer_template

#1 @kevdotbadger
7 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)?

#2 @ocean90
7 years ago

  • Milestone Awaiting Review
  • Resolutionduplicate
  • Status newclosed

Hello @kevdotbadger, thanks for the ticket and the patch.

We're already tracking this issue in #13239 and #42855.

#3 @kevdotbadger
7 years ago

@ocean90 This is being tracked in a 10 year old ticket. You being serious?

Note: See TracTickets for help on using tickets.