1

I am trying to extend twentyseventeen theme. I want to achieve two simple goals.

  1. No custom header image
  2. Don't show the Title and tagline by default.

But I would like to keep those options available for the end user if he/she wishes to re-enable to show the title and tagline or add new custom image.

I have been trying with customizer api but not working..

Essentially if I apply child theme.. Customizer should have the checkbox unchecked for "Display Site Title and Tagline" in "Site Identity". Also "Header Media" -> "Current Header" to be null. Also in the page those settings should be reflected.

Things which I tried..

function themeslug_customize_register( $wp_customize ) {
  // Do stuff with $wp_customize, the WP_Customize_Manager object.
  // TRY 1 - DID NOT WORK
  $wp_customize->get_setting( 'header_text' )->default = 0;
  // TRY 2 - DID NOT WORK
  $wp_customize->add_setting('header_text',
     array(
        'theme_supports'    => array( 'custom-logo', 'header-text' ),
        'default'           => 0,
        'sanitize_callback' => 'absint',
     )
  );
  // TRY 3 - DID NOT WORK
  $wp_customize->get_setting( 'blogdescription' )->default = 'Custom test';

}
add_action( 'customize_register', 'themeslug_customize_register' );

// TRY 4 - this works.. BUT this removes the setting altogether leaving no option to bring 

// back custom header. So this undesirable. add_action( 'after_setup_theme', 'remove_featured_images_from_child_theme', 11 ); function remove_featured_images_from_child_theme() { remove_theme_support( 'custom-header' ); }

Your Answer

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

Browse other questions tagged or ask your own question.