Child Theme disable customizer defaults

admin2025-06-06  3

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' ); }

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749179502a317028.html

最新回复(0)