0

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.

enter image description here

enter image description here

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

2
  • 1
    Changning the sanitize callback to sanitize_text_field seems to have fixed the issue
    – adviner
    Oct 16, 2020 at 5:44
  • Write the answer for your question then
    – Lenin
    Oct 16, 2020 at 6:09

1 Answer 1

0

The solution was to change the sanitize callback to sanitize_text_field seems to have fixed the issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.