Use radio value from $wp_customize->add_control in function
-
function wf_customize_register( $wp_customize ) { // Colour Schemes $wp_customize->add_section('colour_scheme', array( 'title' => __('Colour Scheme', 'wf'), 'priority' => 200, )); $wp_customize->add_setting('wf_theme_options[colour_scheme]', array( 'default' => 'jungle', 'type' => 'option', 'capability' => 'edit_theme_options', )); $wp_customize->add_control('colour_scheme', array( 'label' => __('Colour Scheme', 'wf'), 'section' => 'colour_scheme', 'settings' => 'wf_theme_options[colour_scheme]', 'type' => 'radio', 'choices' => array( 'jungle' => 'Jungle', 'sea' => 'Sea', 'mountain' => 'Mountain', 'woods' => 'Woods', 'desert' => 'Desert', ), )); } add_action( 'customize_register', 'wf_customize_register' ); function wf_customize_css() { $mods = get_theme_mods(); var_dump($mods); $skin = get_theme_mod('wf_theme_options'); ?> <link rel="stylesheet" href="<?php bloginfo('template_directory') ?>/css/<?php echo $skin ?>.css" /> <?php } add_action( 'wp_head', 'wf_customize_css');
I’m using customize_register( $wp_customize ) to add a skin/colour scheme option to my theme but don’t know how to grab the value from the radio button in the menu.
When I do a var_dump, the output contains:
["wonderfort_theme_options"]=> array(1) { ["colour_scheme"]=> string(3) "sea" }
How do I grab the ‘sea’ to use where $skin is? Currently it echos ‘Array’.
Thanks.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Use radio value from $wp_customize->add_control in function’ is closed to new replies.