php - Wordpress Customizer API: access variables -
i have following code:
function color_scheme_customizer_register($wp_customize) { $wp_customize->add_section('front_page', array( 'title' => __('front page'), 'priority' => 120, )); // main image $wp_customize->add_setting('front_page_options[image_select]', array( 'capability' => 'edit_theme_options', 'type' => 'option', )); $wp_customize->add_control( new wp_customize_image_control($wp_customize, 'image_select', array( 'label' => __('main image', 'themename'), 'section' => 'front_page', 'settings' => 'front_page_options[image_select]', ))); // feature 1 $wp_customize->add_setting('front_page_options[feature_one_page]', array( 'capability' => 'edit_theme_options', 'type' => 'option', )); $wp_customize->add_control('feature_one_page', array( 'label' => __('featured page one'), 'section' => 'front_page', 'settings' => 'front_page_options[feature_one_page]', 'type' => 'dropdown-pages', )); $wp_customize->add_setting('front_page_options[feature_one_textarea]', array( 'capability' => 'edit_theme_options', 'type' => 'option', )); $wp_customize->add_control('feature_one_textarea', array( 'label' => __('featured page 1 summary'), 'section' => 'front_page', 'settings' => 'front_page_options[feature_one_textarea]', 'type' => 'textarea', )); ... } i want access front_page_array variables, can find documentation on creating new .css spreadsheet make changes. there way can access variables so:
<?php get_header(); ?> <?php get_customizer_variables('front_page_options'); ?> <?php get_footer(); ?>
to retrieve values have stored, either use get_theme_mod() or get_option(), depending on "type" set. if no type given, defaults theme_mod. retrieve field, use like:
get_option( 'front_page_options[image_select]', '' ); alternatively, if have multiple options, can retrieve of them in array , access them needed.
$front_page_options = get_option( 'front_page_options', '' ); $image_select = $front_page_options['image_select']; this simple example should give idea of how access values looking for.
Comments
Post a Comment