Php Wordpress文本自定义程序字段返回0

Php Wordpress文本自定义程序字段返回0,php,wordpress,wordpress-theming,Php,Wordpress,Wordpress Theming,这是我关于堆栈溢出的第一篇文章 因此,我正在深入研究WordPress定制器API,但似乎无法掌握其中的诀窍。我已经注册了一个文本字段,并让它在customizer中工作,但只要我提交值并检查前端,我就会得到一个“0”返回值,无论我尝试什么。我有什么遗漏吗?这是我的密码: function neu_customize_register( $wp_customize ) { $wp_customize->add_section( 'neuport_header_settin

这是我关于堆栈溢出的第一篇文章

因此,我正在深入研究WordPress定制器API,但似乎无法掌握其中的诀窍。我已经注册了一个文本字段,并让它在customizer中工作,但只要我提交值并检查前端,我就会得到一个“0”返回值,无论我尝试什么。我有什么遗漏吗?这是我的密码:

    function neu_customize_register( $wp_customize ) {

    $wp_customize->add_section( 'neuport_header_settings' , array(
        'title'      => __( 'Header Settings', 'neuport' ),
        'priority'   => 30,
    ) );

    $wp_customize->add_setting( 'header_text', array(
        'default'           => __( 'default text', 'neuport' ),
        'type'              => 'theme_mod',
        'capability' => 'edit_theme_options',
        'sanitize_callback' => 'our_sanitize_function',
   ) );

    // Add control
    $wp_customize->add_control( new WP_Customize_Control(
        $wp_customize,
        'neuport_header_settings',
            array(
                'label'    => __( 'Header Text', 'neuport' ),
                'section'  => 'neuport_header_settings',
                'settings' => 'header_text',
                'type'     => 'text'
            )
        )
    );
    function our_sanitize_function( $input ) {
        return wp_kses_post( force_balance_tags( $input ) );
    }
 }
 add_action( 'customize_register', 'neu_customize_register' );
然后,在此之后,我将使用它在前端显示:

    <h1 class="logo">
        <a href="<?php home_url(); ?>">
         <?php echo get_theme_mod( 'header_text'); ?>
        </a>
    </h1>

这可能是摆在我面前的东西,但我对定制师还是那么陌生。我真的非常感谢你的帮助!谢谢大家