WordPress customizer

  wordpress

Dodanie nowej opcji szablonu

Controls: elementy formularza
Settings: pod jaką nazwą w bazie zapisze się nowe ustawienie
Sections: sekcje

function addSocialLinks( $wp_customize ) {
    $wp_customize->add_setting('social_fb', array(
        'default' => '',
        'transport' => 'refresh',
    ));
    $wp_customize->add_section('social_media_links', array(
        'title' => __('Social media', 'Publico 24'),
        'priority' => 30
    ));
    $wp_customize->add_control(new WP_Customize_Control(
        $wp_customize,
        'your_setting_id',
        array(
            'label'          => __( 'Facebook', 'theme_name' ),
            'section'        => 'social_media_links',
            'settings'       => 'social_fb',
            'type'           => 'text'            
        )
    ));
}
add_action('customize_register', 'addSocialLinks');

Następnie w szablonie

get_theme_mod('social_fb')