I have a theme option that I use for opacity. On the screen, I put 0.67 as the value. But if I publish and refresh to look at the value it's coming up as 0-67.
Here is my code:
$wp_customize->add_setting( 'mctheme_option_headernav_background_opacity', array (
'default' => '0.67',
'sanitize_callback' => 'sanitize_title',
'type' => 'theme_mod',
));
$wp_customize->add_control('mctheme_option_headernav_background_opacity', array(
'type' => 'text',
'label' => esc_html__('Header/Navigation Background Opacity', 'mctheme' ),
'section' => 'colors'
));
and the used in the code used in the theme:
get_theme_mod('mctheme_option_headernav_background_opacity', '0.67')
Is there any reason this is happening? I tried changing the control type to number but that didnt work either
I have a theme option that I use for opacity. On the screen, I put 0.67 as the value. But if I publish and refresh to look at the value it's coming up as 0-67.
Here is my code:
$wp_customize->add_setting( 'mctheme_option_headernav_background_opacity', array (
'default' => '0.67',
'sanitize_callback' => 'sanitize_title',
'type' => 'theme_mod',
));
$wp_customize->add_control('mctheme_option_headernav_background_opacity', array(
'type' => 'text',
'label' => esc_html__('Header/Navigation Background Opacity', 'mctheme' ),
'section' => 'colors'
));
and the used in the code used in the theme:
get_theme_mod('mctheme_option_headernav_background_opacity', '0.67')
Is there any reason this is happening? I tried changing the control type to number but that didnt work either
Share Improve this question asked Oct 16, 2020 at 5:40 advineradviner 1116 bronze badges 2- 1 Changning the sanitize callback to sanitize_text_field seems to have fixed the issue – adviner Commented Oct 16, 2020 at 5:44
- Write the answer for your question then – Lenin Commented Oct 16, 2020 at 6:09
1 Answer
Reset to default 0The solution was to change the sanitize callback to sanitize_text_field seems to have fixed the issue