# Simple Site Details Settings Page

> Adds Settings > Site Details where you can store your phone number, address and opening hours once, then show them anywhere with [wpide_site_detail key="phone"].

- Type: PHP
- Runs: Run everywhere
- Category: [Developer](https://wpide.com/library/category/developer/)
- Tags: settings, options, shortcode, contact
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/dev-site-options-page/

## Code

```php
$wpide_site_fields = array(
    'phone'   => 'Phone number',
    'email'   => 'Contact email',
    'address' => 'Address',
    'hours'   => 'Opening hours',
);

add_action( 'admin_init', function () use ( $wpide_site_fields ) {
    register_setting( 'wpide_site_details', 'wpide_site_details', array(
        'type'              => 'array',
        'default'           => array(),
        'sanitize_callback' => function ( $input ) use ( $wpide_site_fields ) {
            $clean = array();

            foreach ( array_keys( $wpide_site_fields ) as $key ) {
                $clean[ $key ] = isset( $input[ $key ] ) ? sanitize_textarea_field( $input[ $key ] ) : '';
            }

            return $clean;
        },
    ) );
} );

add_action( 'admin_menu', function () use ( $wpide_site_fields ) {
    add_options_page( 'Site Details', 'Site Details', 'manage_options', 'wpide-site-details', function () use ( $wpide_site_fields ) {
        $values = (array) get_option( 'wpide_site_details', array() );

        echo '<div class="wrap"><h1>Site Details</h1><form method="post" action="options.php">';
        settings_fields( 'wpide_site_details' );
        echo '<table class="form-table" role="presentation">';

        foreach ( $wpide_site_fields as $key => $label ) {
            printf(
                '<tr><th scope="row"><label for="wpide-%1$s">%2$s</label></th><td><textarea class="large-text" rows="2" id="wpide-%1$s" name="wpide_site_details[%1$s]">%3$s</textarea><p class="description"><code>[wpide_site_detail key="%1$s"]</code></p></td></tr>',
                esc_attr( $key ),
                esc_html( $label ),
                esc_textarea( isset( $values[ $key ] ) ? $values[ $key ] : '' )
            );
        }

        echo '</table>';
        submit_button();
        echo '</form></div>';
    } );
} );

add_shortcode( 'wpide_site_detail', function ( $atts ) {
    $atts   = shortcode_atts( array( 'key' => '' ), $atts, 'wpide_site_detail' );
    $values = (array) get_option( 'wpide_site_details', array() );
    $value  = isset( $values[ $atts['key'] ] ) ? $values[ $atts['key'] ] : '';

    return nl2br( esc_html( $value ) );
} );
```

## Notes

Edit $fields to add more details. Values are stored in the wpide_site_details option.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Simple Site Details Settings Page" 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/
