Customizer Register WordPress Theme Setting Simple

Very simple example…

 

 

function sinan_customizer_register($wp_customize){

    $wp_customize->add_section( 'section_name', array(
        'title' => 'Text Title',
        'description' => 'Text descripotion sometin hee'
    ) );


    $wp_customize->add_setting( 'setting_name', array(
        'type' => 'theme_mod',
        'default' => 'default text here',
        'sanitize_callback' => 'esc_attr'
    ) );


    $wp_customize->add_control( 'control_name', array(
        'label' => 'Text Label ',
        'description' => 'Text descripotion sometin hee',
        'section' => 'section_name',
        'settings' => 'setting_name',
        'type' => 'text'
    ) );


}

add_action( 'customize_register', 'sinan_customizer_register' );

 

and this is how you get your setting pick one;

get_theme_mod('setting_name');

echo get_theme_mod('setting_name');

$var = get_theme_mod('setting_name');

 

 

For more info check this: https://divpusher.com/blog/wordpress-customizer-sanitization-examples/

and this: https://codex.wordpress.org/Theme_Customization_API

 

and Check this out to understand layout

 

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments