• Resolved Mike DeLuna

    (@mikedeluna)


    Hi,

    Fun theme!

    I’m trying to override the parent theme’s custom-header.php but running into a problem. Specifically, I want to change the dimensions from 1280 x 300 to a custom (bigger) size.

    I copied the file from the parent and matched the folder structure in the child (i.e, it’s in “inc”). I changed the dimensions in the child custom-header.php, but when I went to upload an image, it still showed the parent’s dimensions.

    What am I doing wrong? Does something need to go into the child theme’s functions.php?

    Thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter Mike DeLuna

    (@mikedeluna)

    Well, I figured it out, if anyone is interested. Not sure if this is the proper way of doing it, but this is what worked for me.

    You do not need a custom-header.php in your child theme. The first thing to do is to remove the action that defines the custom header attributes in custom-header.php. Create a child theme functions.php and put this in it:

    // remove default action from simone
    remove_action( 'after_setup_theme', 'simone_custom_header_setup' );

    Next, copy the function you want to change from custom-header.php and paste it into the child’s functions.php. Then change whatever attribute you want and add the action back (make sure to use your child theme’s name in the appropriate places). This is what it looked like for me:

    // define new custom header size
    function yourchildthemename_custom_header_setup() {
    	add_theme_support( 'custom-header', apply_filters( 'simone_custom_header_args', array(
    		'default-image'          => '',
    		'default-text-color'     => 'ffffff',
    		'width'                  => 1800,
    		'height'                 => 1200,
    		'flex-height'            => true,
    		'wp-head-callback'       => 'simone_header_style',
    		'admin-head-callback'    => 'simone_admin_header_style',
    		'admin-preview-callback' => 'simone_admin_header_image',
    	) ) );
    }
    add_action( 'after_setup_theme', 'yourchildthemename_custom_header_setup' );

    In my case, I had to add one additional thing to my css to make my image full width:

    .header-image img {
      width: 100%;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Override custom-header.php’ is closed to new replies.