CSS properties in textarea in the Customizer

The question:

I am trying to create a custom field (text/CSS code in textarea) that include the CSS suggestion like Additional CSS in the customizer:
https://i.postimg.cc/9QhLPgVk/image.png.

Does everybody has experience with that?

I need any solution like the above screenshot here: https://i.postimg.cc/L55cpChD/image.png.

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

As it happens, I was literally just doing some stuff with the customizer.

You can use the following class to get what you need..

WP_Customize_Code_Editor_Control

I’ll include it in the control ready to go.

$wp_customize->add_control( new WP_Customize_Code_Editor_Control( $wp_customize, 'favorite_html', array(
        'label' => 'Theme CSS',
        'description' => '',
        'code_type' => 'text/css',
        'section' => 'section_id',
        'settings' => 'settings_control'
    )));


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment