Using WordPress ‘customizer_widgets_section_args’ PHP filter

The customizer_widgets_section_args WordPress PHP filter allows you to modify the Customizer widget section arguments for a specific sidebar.

Usage

add_filter('customizer_widgets_section_args', 'your_custom_function', 10, 3);

function your_custom_function($section_args, $section_id, $sidebar_id) {
    // your custom code here
    return $section_args;
}

Parameters

  • $section_args (array): Array of Customizer widget section arguments.
  • $section_id (string): Customizer section ID.
  • $sidebar_id (int|string): Sidebar ID.

More information

See WordPress Developer Resources: customizer_widgets_section_args

Examples

Modify the section title

Change the title of the widget section in the Customizer.

add_filter('customizer_widgets_section_args', 'change_section_title', 10, 3);

function change_section_title($section_args, $section_id, $sidebar_id) {
    if ($sidebar_id == 'your_sidebar_id') {
        $section_args['title'] = 'Your New Title';
    }
    return $section_args;
}

Modify the section description

Update the description of the widget section in the Customizer.

add_filter('customizer_widgets_section_args', 'change_section_description', 10, 3);

function change_section_description($section_args, $section_id, $sidebar_id) {
    if ($sidebar_id == 'your_sidebar_id') {
        $section_args['description'] = 'Your New Description';
    }
    return $section_args;
}

Change the section priority

Change the priority of the widget section in the Customizer.

add_filter('customizer_widgets_section_args', 'change_section_priority', 10, 3);

function change_section_priority($section_args, $section_id, $sidebar_id) {
    if ($sidebar_id == 'your_sidebar_id') {
        $section_args['priority'] = 5;
    }
    return $section_args;
}

Change the section capability

Update the capability required to access the widget section in the Customizer.

add_filter('customizer_widgets_section_args', 'change_section_capability', 10, 3);

function change_section_capability($section_args, $section_id, $sidebar_id) {
    if ($sidebar_id == 'your_sidebar_id') {
        $section_args['capability'] = 'manage_options';
    }
    return $section_args;
}

Modify the section theme_supports

Update the theme_supports argument for the widget section in the Customizer.

add_filter('customizer_widgets_section_args', 'change_section_theme_supports', 10, 3);

function change_section_theme_supports($section_args, $section_id, $sidebar_id) {
    if ($sidebar_id == 'your_sidebar_id') {
        $section_args['theme_supports'] = 'custom-header';
    }
    return $section_args;
}