0

I'm looking for a way to remove the Section font_selection and move the Control body_font_family straight to the Panel font_panel using Child Theme functions.php. Below is the sample CODE from parent theme's customizer.php:

//PANEL
$wp_customize->add_panel( 'font_panel', array(
    'priority'       => 17,
    'capability'     => 'edit_theme_options',
    'theme_supports' => '',
    'title'          => __('Fonts', 'theme'),
) );

//SECTION
$wp_customize->add_section(
    'font_selection',
    array(
        'title'     => __('Font selection', 'theme'),
        'priority'  => 10,
        'panel'     => 'font_panel',            
        )
    )
);

//SETTING
$wp_customize->add_setting(
    'body_font_family',
    array(
        'sanitize_callback' => 'theme_sanitize_text',
        'default' => $defaults['body_font_family'],
    )
);

//CONTROL
$wp_customize->add_control(
    'body_font_family',
    array(
        'label' => __( 'Body font', 'theme' ),
        'section' => 'font_selection',
        'type' => 'text',
        'priority' => 12
    )
);   
0

Assuming that the parent theme is running the above code at customize_register priority 10, you just have to add another customize_register action callback that runs afterward, like at 20. However, you cannot move a control to a panel. Controls can only reside inside of sections. To move a control to another section you can use:

add_action( 'customize_register', function ( WP_Customize_Manager $wp_customize ) {
    $wp_customize->remove_section( 'font_selection' );
    $wp_customize->add_section( 'some_other_section', array(
        'title' => __( 'Some other section', 'theme' ),
    ) );

    $body_font_family_control = $wp_customize->get_control( 'body_font_family' );
    if ( $body_font_family_control ) {
        $body_font_family_control->section = 'some_other_section';
    }
}, 20 );
0

Possible to move widgets control to another section ?

Like sidebar_widgets want to move my_section

$sidebars_widgets_control = $wp_customize->get_control( 'sidebars_widgets-foot_sidebar' );
    if ( $sidebars_widgets_control ) {
        $sidebars_widgets_control->section = 'my_settings';
    }
}, 20 );

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.