Rename and rearrange customizer section

I’m trying to rename and rearange the Widgets panel in WP Customizer area (apperance > customizer). So far I’ve only tried to rename the section, I would also like to move it to the bottom.

I’m using this code:

    $wp_customize->get_section('widgets')->title = __( 'Sidebar & Footer widgets' );

Here’s the complete code:

function my_customize_register() {     
global $wp_customize;

//Remove various sections
$wp_customize->remove_section( 'fl-js-code-section' ); //  JavaScript code box
$wp_customize->remove_section( 'fl-head-code-section' );  //  Head code box
$wp_customize->remove_section( 'fl-header-code-section' );  //  Header code box
$wp_customize->remove_section( 'fl-footer-code-section' );   //  Footer code box
$wp_customize->remove_section( 'custom_css' ); // Additonal css box

// Rename various sections
$wp_customize->get_section('widgets')->title = __( 'Sidebar Footer widgets' );  
} 

add_action( 'customize_register', 'my_customize_register', 11);

But when I save and reload customizer I keep getting the following warning

Warning: Creating default object from empty value in /home/siteid4/public_html/_test4/wp-content/themes/bb-theme-child/functions.php on line 51

Line 51 is the code renaming the widgets section.

The weird thing is that there are various section NOT from wordpress, they are added by other plugins. Those I have no problem renaming, it’s only the WP sections I am having trouble with.

Any idea on how to rename and move this section?

2 Answers
2

Figured it out. Use “get_panel” not “get_section”

    $wp_customize->get_panel('widgets')->title = __( 'Sidebar & Footer widgets' );

Leave a Comment