1

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

Figured it out. Use "get_panel" not "get_section"

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

Rename and Re-arrange the Widgets panel in WP customizer area in appearance > customizer.

http://natko.com/changing-default-wordpress-theme-customization-api-sections/

function customize_register_init( $wp_customize ){
    $wp_customize->get_section('colors')->title = __( 'Theme Colors' );
    $wp_customize->get_section('colors')->priority = 500;
}
add_action( 'customize_register', 'customize_register_init' );

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

you can wrong section name enter in remove_section or get_section.

I hope is useful.

  • After more troubleshooting I think this might be limited to the Widget panel that WP includes by default. I'm looking at WP doc codex.wordpress.org/Theme_Customization_API and it mentions several default panels but not the Widgets panel. Makes me think it's not designed to be renamed. – Treb Mar 31 '17 at 9:44
  • 1
    By the way I am able to use the code above to rename other panels, just not this one. The only other thing I can think off is that it's not called "widgets". – Treb Mar 31 '17 at 9:45

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.