WordPress.org

Ready to get started?Download WordPress

Forums

Create more than one section in Theme Customizer (1 post)

  1. tanotify
    Member
    Posted 1 year ago #

    I tried to create more than one section in Theme Customizer, but had no success with that.

    /* Theme customize - Create menu bar link */
    function example_customizer_menu() { add_theme_page( 'Customize', 'Customize', 'edit_theme_options', 'customize.php' ); }
    add_action( 'admin_menu', 'example_customizer_menu' );

    How i got it for all of new sections (tabs) in Theme Customizer i must to write code below. Is it right?

    /* Create one new tab */
    add_action('customize_register', 'themedemo_customize');
    function themedemo_customize($wp_customize) {
    
    $wp_customize->add_section( 'themedemo_demo_settings', array(
        'title'          => 'Demonstration Stuff',
        'priority'       => 35,
    ) );
    
    $wp_customize->add_setting( 'some_setting', array(
        'default'        => 'default_value',
    ) );
    
    $wp_customize->add_control( 'some_setting', array(
        'label'   => 'Text Setting',
        'section' => 'themedemo_demo_settings',
        'type'    => 'text',
    ) );
    
    $wp_customize->add_section( 'themedemo_demo_settings', array(
        'title'          => 'Demonstration Stuff',
        'priority'       => 40,
    ) );
    
    $wp_customize->add_setting( 'some_other_setting', array(
        'default'        => '#000000',
    ) );
    
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'some_other_setting', array(
        'label'   => 'Color Setting',
        'section' => 'themedemo_demo_settings',
        'settings'   => 'some_other_setting',
    ) ) );
    
    }

    For what did we use "customize_register" and why there is always different words? How i got it "themedemo_customize" it is like parameter here..

    add_action('customize_register', 'themedemo_customize');
    function themedemo_customize($wp_customize) {

    I read official documentation but did not get it.

Topic Closed

This topic has been closed to new replies.

About this Topic