0

I am creating a child theme using twenty fourteen as the parent theme. I want my child theme to include a custom header image by default. This header image can be set in the theme's custom settings, but can I specify it in my child theme style.css?

I've been searching google for over an hour with no success.

0

Yes, there is possible.

Inside the functions.php add the follow source.

add_action( 'after_setup_theme', 'twentyfourteen_default_header' );
/**
 * Add Default Custom Header Image To Twenty Fourteen Theme
 * 
 * @return void
 */
function twentyfourteen_default_header() {

    add_theme_support(
        'custom-header',
        apply_filters(
            'twentyfourteen_custom_header_args',
            array(
                'default-text-color' => 'fff',
                'default-image' => get_stylesheet_directory_uri() . '/images/default_header.jpg',
            )
        )
    );
}

Now was the set the default image, from the path. The rest is a little bid css magic to set to your requirements. Alternative you can set also a image via CSS, but is not so easy to change for the theme users. With this function you set a default and the custom possibilities like Customizer or via back end is also possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.