Make WordPress Core

Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#23157 closed defect (bug) (invalid)

Custom header in twenty twelve theme not pluggable/filterable

Reported by: adamrice Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.5
Component: Bundled Theme Keywords:
Focuses: Cc:


Child themes cannot cleanly alter the header styling output from the twenty twelve theme in inc/custom-header.php

I propose a change from

function twentytwelve_header_style()


if ( ! function_exists( 'function twentytwelve_header_style' ) ) :
function twentytwelve_header_style()

Change History (6)

comment:1 follow-up: toscho15 months ago

  • Cc info@… added
  • Resolution set to invalid
  • Status changed from new to closed

No need to make this function pluggable. Just remove it in your child theme per hook, and use your own setup function then:

add_action( 'after_setup_theme', 'disable_parent_custom_header', 9 );
function disable_parent_custom_header()
	remove_action( 'after_setup_theme', 'twentytwelve_custom_header_setup' );

comment:2 SergeyBiryukov15 months ago

  • Milestone Awaiting Review deleted

comment:3 in reply to: ↑ 1 ; follow-up: paulwp15 months ago


Why does 9 work instead of 11 ?

I've been searching everywhere for the answer as to why in this particular case the priority lower than 10 (like 9 as you used in the example above) works instead of priority more than 10 like 11.

Child's function is loaded first, when there are 2 functions, 1 is from parent and 1 from child, both are hooking to the same after_setup_theme(), the add and remove and the order of file being loaded doesn't seem right.

Is this a bug in after_setup_theme() ?

comment:4 in reply to: ↑ 3 ; follow-up: toscho15 months ago

Replying to paulwp:

Why does 9 work instead of 11 ?

When the child theme’s functions.php is loaded the parent theme’s action is not yet bound to the hook. So you have to wait until 'after_setup_theme' is actually called, then remove the callback registered with a lower priority. But you have to do this earlier than the callback, otherwise the callback will be done already.

comment:5 in reply to: ↑ 4 paulwp15 months ago

Replying to toscho:

But you have to do this earlier than the callback, otherwise the callback will be done already.

Thanks a lot !

comment:6 adamrice15 months ago

@toscho — thanks for the explanation.

Note: See TracTickets for help on using tickets.