• Resolved WebHunt Infotech

    (@webhuntinfotech)


    Hi,

    How to modify dropdown select box using “Child-Theme”.

    We tried it lot of time. but still we can’t edit/modify it.

    So please assist me how to modify it using “child-theme”.

    Either you can provide the idea how to delete field from customizer.

    Thank You

    https://ww.wp.xz.cn/plugins/kirki/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Can you please elaborate?
    Which dropdown do you want to modify?
    What do you want to do exactly?
    Do you mean you want to modify ALL dropdowns? And if so, how would you like to make them?

    Hi,

    No, we want to modify only one dropdown.

    Here is a code.

    This as a actual code in matrix theme.

    Kirki::add_field('matrix_theme', array(
        'settings' => 'color_scheme',
        'label' => __('Select Color Scheme', 'matrix'),
        'section' => 'general_sec',
        'type' => 'select',
        'priority' => 10,
        'default' => $matrix_theme_options['color_scheme'],
        'choices' => array(
            'red' => __('Default', 'matrix'),
            'green' => __('Green', 'matrix'),
            'cyan' => __('Cyan', 'matrix')
        ),
        'sanitize_callback' => 'matrix_sanitize_text'
    ));

    Now we created a “Child-Theme” for matrix theme.

    And we want to modify above code with this.

    Kirki::add_field('matrix_theme', array(
        'settings' => 'color_scheme',
        'label' => __('Select Color Scheme', 'matrix'),
        'section' => 'general_sec',
        'type' => 'select',
        'priority' => 10,
        'default' => $matrix_theme_options_child['color_scheme'],
        'choices' => array(
            'blue' => __('Default', 'matrix'),
    		'red' => __('Red', 'matrix'),
            'green' => __('Green', 'matrix'),
            'cyan' => __('Cyan', 'matrix')
        ),
        'sanitize_callback' => 'matrix_sanitize_text_child'
    ));

    You can see our matrix theme package here:

    Matrix

    Thank you

    ok, now I understand.

    The problem with the Matrix theme is that Kirki is embedded in the theme , so when you try to add the code above in a child theme’s functions.php file, it runs before Kirki has been loaded and throws a PHP error.

    You will have to wrap that call in a function and then add the function on after_setup_theme.

    Example:

    function my_custom_child_theme_controls() {
    	Kirki::add_field('matrix_theme', array(
    		'settings' => 'color_scheme',
    		'label' => __('Select Color Scheme', 'matrix'),
    		'section' => 'general_sec',
    		'type' => 'select',
    		'priority' => 10,
    		'default' => 'red',
    		'choices' => array(
    			'blue' => __('Blue', 'matrix'),
    			'red' => __('Default', 'matrix'),
    			'green' => __('Green', 'matrix'),
    			'cyan' => __('Cyan', 'matrix')
    		),
    		'sanitize_callback' => 'matrix_sanitize_text'
    	));
    }
    add_action( 'after_setup_theme', 'my_custom_child_theme_controls' );

    I hope that helps!

    Thread Starter WebHunt Infotech

    (@webhuntinfotech)

    Hi,

    We will try this.

    Thank you for your kind support

    Thread Starter WebHunt Infotech

    (@webhuntinfotech)

    Its working for me.

    Thank You

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Modify kirki customizer dropdown using "Child-Theme"’ is closed to new replies.