# Add Your Own Setting to the Customizer

> Adds a "Site extras" section to Appearance > Customize with a footer note and a contact phone field that preview live, and makes them available with a [site_extra] shortcode, as a pattern for your own settings.

- Type: PHP
- Runs: Run everywhere
- Category: [Developer](https://wpide.com/library/category/developer/)
- Tags: customizer, settings, theme-mods
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/dev-customizer-setting-example/

## Code

```php
add_action( 'customize_register', function ( $wp_customize ) {
    $wp_customize->add_section( 'wpide_site_extras', array(
        'title'    => 'Site extras',
        'priority' => 160,
    ) );

    $wp_customize->add_setting( 'wpide_footer_note', array(
        'default'           => '',
        'sanitize_callback' => 'wp_kses_post',
        'transport'         => 'refresh',
    ) );
    $wp_customize->add_control( 'wpide_footer_note', array(
        'label'   => 'Footer note',
        'section' => 'wpide_site_extras',
        'type'    => 'textarea',
    ) );

    $wp_customize->add_setting( 'wpide_phone', array(
        'default'           => '',
        'sanitize_callback' => 'sanitize_text_field',
    ) );
    $wp_customize->add_control( 'wpide_phone', array(
        'label'   => 'Contact phone',
        'section' => 'wpide_site_extras',
        'type'    => 'tel',
    ) );
} );

add_action( 'init', function () {
    add_shortcode( 'site_extra', function ( $atts ) {
        $atts = shortcode_atts( array( 'key' => 'footer_note' ), $atts, 'site_extra' );
        $key  = 'phone' === $atts['key'] ? 'wpide_phone' : 'wpide_footer_note';
        return wp_kses_post( (string) get_theme_mod( $key, '' ) );
    } );
} );
```

## Notes

Use [site_extra key="phone"] or get_theme_mod( 'wpide_phone' ) in templates; block themes need the Customize menu brought back to edit them.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Add Your Own Setting to the Customizer" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
