WordPress.org

Support

Support » Themes and Templates » [Resolved] How to override args for custom-header from child theme?

[Resolved] How to override args for custom-header from child theme?

  • I’ve fell behind a bit on recent updates to WP things, and have found myself stumbling….

    How would one modify any of the args set when defining custom-header with add theme support from a child theme?

    My specific scenario is that I’ve widened the twenty twelve theme, and would like to modify the header width to match – specifically seen in twentytwelve_custom_header_setup within custom-header.php.

    function twentytwelve_custom_header_setup() {
    	$args = array(
    		// Text color and image (empty to use none).
    		'default-text-color'     => '444',
    		'default-image'          => '',
    
    		// Set height and width, with a maximum value for the width.
    		'height'                 => 250,
    		'width'                  => 960,
    		'max-width'              => 2000,
    
    		// Support flexible height and width.
    		'flex-height'            => true,
    		'flex-width'             => true,
    
    		// Random image rotation off by default.
    		'random-default'         => false,
    
    		// Callbacks for styling the header and the admin preview.
    		'wp-head-callback'       => 'twentytwelve_header_style',
    		'admin-head-callback'    => 'twentytwelve_admin_header_style',
    		'admin-preview-callback' => 'twentytwelve_admin_header_image',
    	);
    
    	add_theme_support( 'custom-header', $args );
    }
    add_action( 'after_setup_theme', 'twentytwelve_custom_header_setup' );

    Thanks in advance for any guidance! I’ve worn out Google, and haven’t had any coffee today – I’ll probably kick myself when I see it.

    I’ve tried what I think are the normal tricks… my own function on after_setup_theme with a lower priority, removing and readding support… I’m fumbling!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael

    @alchymyth

    Forum Moderator

    this worked for me for the header height – no priority changes; code in functions.php of the child theme:

    function twentytwelvechild_custom_header_setup() {
    	$header_args = array( 'height' => 175 );
    	add_theme_support( 'custom-header', $header_args );
    }
    add_action( 'after_setup_theme', 'twentytwelvechild_custom_header_setup' );

    I’ll try it again… I’m nearly certain I did the same

    I actuall copied the function from 2012 to my child theme, renamed it, edited it, and gave it a go, that didn’t work – I’ll copy what you’ve got here and give it a go, much appreciated

    I’ll be darned… whatever I did had a mistake obviously….

    Your code works perfectly, and thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] How to override args for custom-header from child theme?’ is closed to new replies.
Skip to toolbar