Make WordPress Core

Opened 3 years ago

Closed 4 months ago

#42921 closed defect (bug) (invalid)

get_header('customheadername') is fetching the header.php even i have provided customheadername

Reported by: mausamrai Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9.1
Component: Themes Keywords: reporter-feedback close
Focuses: template Cc:


get_header() is not supporting the custom headername provided. so fetching default header.php

Change History (4)

#1 @Compute
3 years ago

What is the name of your header file? The filename should be header-{$name}.php where $name is the argument you are using in get_header().

Like get_header( 'customheadername' ) should be header-customheadername.php.

See: https://developer.wordpress.org/reference/functions/get_header/

#2 @johnbillion
3 years ago

  • Keywords reporter-feedback added

#3 @hellofromTonya
5 months ago

  • Keywords close added

Hello @mausamrai,

Does this problem still persist for you today?

If yes, does a template file exist for the custom header, i.e. a file named: header-customheadername.php?

How does this work?

WordPress will load custom header templates when the header-{template name}.php file exists; else, the default template is loaded.

You can find more information here https://developer.wordpress.org/reference/functions/get_header/.

As @ Compute notes, I too suspect the problem is due to a mismatch of the name passed to the function and the template's filename. I'm marking this ticket as a close worksforme candidate. Please don't be alarmed. We mark tickets for close consideration when we are unable to reproduce and suspect the problem is not due to WordPress core. However, when more information is given, we reevaluate.

#4 @hellofromTonya
4 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

I'm closing this ticket. However, if the problem persists, please reopen and provide more information to help us further investigate.

Note: See TracTickets for help on using tickets.