I can’t figure out how to get the value - regardless of whether they are set or not - from the checkboxes in the WP Configuration Manager.
This is the code in functions.php:
$wp_customize->add_setting('social_facebook', array(
'type' => 'option',
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'social_facebook',
array(
'label' => __( 'Facebook', 'theme_name' ),
'section' => 'social-icons',
'settings' => 'social_facebook',
'type' => 'checkbox',
)
)
);
And here is how I am trying to get the value:
<?php
$facebook = get_theme_mod('social_facebook');
if ($facebook != ''){?>
<style>
.facebook {display:inline!important;}
</style>
<?php }
?>
These flag values have the value "(empty) or" 1 ", so the system logs their check. However, I don’t know how to get the value through the get_theme_mod method. In addition, they do not have name values, so I can not get the value in the usual way.
source
share