最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Theme options period being replaced

programmeradmin0浏览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.

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
Add a comment  | 

1 Answer 1

Reset to default 0

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论