Home > Enterprise >  Wordpress: For the theme customizer nothing is adding setting,section,control Plz help I did everyth
Wordpress: For the theme customizer nothing is adding setting,section,control Plz help I did everyth

Time:09-23

I was following a WordPress course

the problem is for the theme customizer nothing is adding settings, sections, control

plz tell me if am I making some mistake I spend 4 hours trying to find the mistake the folder structure is correct, it's showing errors If I do something wrong but it's just not showing anything in customize section of the theme

theme-customizer.php code:

<?PHP


function ju_customize_register( $wp_customize ){
    $wp_customize->add_setting( 'ju_facebook_handle', [ 
        'default'   =>  ''
    ]);



    $wp_customize->add_section( 'ju_social_section', [
        'title'     =>  __( 'Udemy Social Settings', 'udemy' ),
        'priority'  =>  30,
        'panel'     =>  'udemy'
    ]);

    $wp_customize->add_control(new WP_Customize_Control(
        $wp_customize,
        'ju_social_facebook_input',
        array(
            'label'          => __( 'Facebook Handle', 'udemy' ),
            'section'        => 'ju_social_section',
            'settings'       => 'ju_facebook_handle'
        )
    ));


}

functions.php file :

<?php 

//setup
define('ju_mode',true);

//includes

include( get_theme_file_path( 'includes/front/enqueue.php' ) );
include( get_theme_file_path( 'includes/setup.php' ) );
include( get_theme_file_path( 'includes/widgets.php' ) );
include( get_theme_file_path( 'includes/theme-customizer.php' ) );




//hooks


   // for scripts
add_action( 'wp_enqueue_scripts','ju_enqueue' );
   // for navbar
add_action('after_setup_theme','ju_setup');

   //for Sidebar 
add_action('widgets_init','ju_widgets');

// for custmizer social icons
add_action( 'customize_register', 'ju_customize_register' );
//shortcodes

CodePudding user response:

You have defined 'panel' => 'udemy' so your section will only display under the section udemy if you don't have any section with id udemy then your code won't show any output as it's looking for section udemy

so if you don't have already existed section with id udemy remove that panel code and your code will show the expected output in the customizer.

TIP: Write section code first then setting code then its controller code, then another setting for a similar section and it's the controller. It will help you understand the connection between section, setting & controller.

  • Related