theme customizer - can a single option pass multiple values?

In my customizer panel I have a radio button for hiding or showing a feature on my WordPress site. However I need to pass multiple values when a single option is selected.

e.g.

the related sections in my functions.php looks like this:

$wp_customize- add_control('blog_setting', array(
    'label' = __("Turn on / off the blog link", 'portfolio'),
    'section' = 'Layout_options',
    'settings' = 'blog_setting',
    'type' = 'radio',
    'choices' = array(
            'block' =   'Blog link visible',
            'none' =   'Blog link hidden'
        ) 
   ) );

and I change the css with this value like this:

function css_customizer(){
?

style type="text/css"
    .blog__Link{display: ?php echo get_theme_mod('blog_setting'); ?}
/style
?php
}

add_action('wp_head', 'css_customizer');




However I need to implement something like this (note **)

 $wp_customize- add_control('blog_setting', array(
        'label' = __("Turn on / off the blog link", 'portfolio'),
        'section' = 'Layout_options',
        'settings' = 'blog_setting',
        'type' = 'radio',
        'choices' = array(
                'block', '1'** =   'Blog link visible',
                'none', '0'**  =   'Blog link hidden'
            ) 
       ) );

and access the second value like this:

function css_customizer(){
?

style type="text/css"
    .blog__Link{display: ?php echo get_theme_mod('blog_setting[0]**'); ?}
    .second_css_class{opacity: ?php echo get_theme_mod('blog_setting[1]**'); ?}
/style
?php
}

add_action('wp_head', 'css_customizer');

Is this possible? I understand that it is possible to use javascript-theme-customizer, but this seems to be over complicated, I simply need to pass multiple values for each option, and be able to access them. thanks.

Topic theme-customizer radio wp-admin custom-field customization Wordpress

Category Web


I understand what you are trying to do, but you are going in the wrong direction here, you can just check if one was selected in your logic and assign the value there like this:

function css_customizer(){
  $blog_setting_val = get_theme_mod('blog_setting');
  $opacity_val = ($blog_setting_val == 'block') ? '1' : '0';
?>

<style type="text/css">
    .blog__Link{display: <?php echo $blog_setting_val; ?>}
    .second_css_class{opacity: <?php echo $opacity_val; ?>}
</style>
<?php
}

add_action('wp_head', 'css_customizer');

that should do it for your particular case.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.