Customizer Example for Adding new section with a simple color selector

Hello
I could not find an example of adding a new section with a new setting for theme customization on admin.php file. This is my admin.php file and it does not add anything to theme customization section.

<?php

namespace App;

/**
 * Theme customizer
 */
add_action('customize_register', function (\WP_Customize_Manager $wp_customize) {


  $wp_customize->add_section( 'mytheme_new_section_name' , array(
  'title'      => __( 'CodersClan Button', 'mytheme' ),
  'priority'   => 30,
  ) );


  $wp_customize->add_control( new \WP_Customize_Image_Control($wp_customize, 'image_control', array(
    'label'    => __('Upload Your Main Logo', 'code_label'),
    'section'  => 'sage_new_section_name',
    'mime_type' => 'image',
)));

$wp_customize->add_setting( 'header_textcolor' , array(
'default'   => '#000000',
'transport' => 'refresh',
) );
$wp_customize->add_setting( 'header_color' , array(
'default'     => '#000000',
'transport'   => 'refresh',
) );



// Add postMessage support
$wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->selective_refresh->add_partial('blogname', [
    'selector' => '.brand',
    'render_callback' => function () {
        bloginfo('name');
    }
]);
});




/**
 * Customizer JS
 */
add_action('customize_preview_init', function () {
wp_enqueue_script('sage/customizer.js', asset_path('scripts/customizer.js'), ['customize-preview'], null, true);
});

I haven’t tried debugging your code, but FWIW there’s a simple example of utilizing the WP customizer in the Sage book

Thanks for the answer. I needed customization for a task for a job application test. I already submit my test with short-code & custom attributes instead of customizer.

This topic was automatically closed after 42 days. New replies are no longer allowed.