How to override parent customizer.php in child theme

502 Views Asked by At

I am new to Wordpress and PHP, and I am trying to create a child theme for the memberlite theme. I would like to add a custom colour scheme to the customizer, but I can't figure out how to either deregister the parent theme's customizer.php, or to modify the current colour schemes. (I'm not sure which is the correct approach).

In the parent theme functions.php:

/* Customizer additions. */
require_once get_template_directory() . '/inc/customizer.php';

Ideally, I would like to de-require that file and add my own.

Any help would be appreciated.

1

There are 1 best solutions below

0
On

to add a setting with a colorpicker, try this code :

const COLOR_SECTION = "color_section";
const SETTING_COLOR1 = "color1";


add_action("customize_register", function (\WP_Customize_Manager $wp_customize) {


    $wp_customize->add_section(
          COLOR_SECTION
        ,
        [
            "title" => "Color section",
            "priority" => 1,
        ]
    );


    $wp_customize->add_setting(
          SETTING_COLOR1
        ,
        [
            "default" => get_theme_mod(SETTING_COLOR1),
            "type" => "theme_mod",
        ]
    );

    $wp_customize->add_control(
          SETTING_COLOR1
        ,
        [
            "label" => "Color 1",
            "type" => "color",
            "section" => COLOR_SECTION,
        ]
    );


});


// example of utilisation of the color
add_filter("the_title", function ($t) {

    $color1 = get_theme_mod(SETTING_COLOR1);

    return "$t - $color1";

});