首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sage wordpress添加自定义寄存器

Sage wordpress添加自定义寄存器
EN

WordPress Development用户
提问于 2022-06-30 09:18:24
回答 1查看 30关注 0票数 0

我在sage wordpress上使用自定义寄存器

代码语言:javascript
复制
//adding setting for copyright text
add_action('customize_register', 'theme_copyright_customizer');

function theme_copyright_customizer($wp_customize) {
    //adding section in wordpress customizer   
    $wp_customize->add_section('copyright_extras_section', array(
        'title'          => 'Copyright Text Section'
    ));

    //adding setting for copyright text
    $wp_customize->add_setting('text_setting', array(
        'default'        => 'Default Text For copyright Section',
    ));

    $wp_customize->add_control('text_setting', array(
        'label'   => 'Copyright text',
        'section' => 'copyright_extras_section',
        'type'    => 'text',
    ));
}

这向我展示了

代码语言:javascript
复制
call_user_func_array() expects parameter 1 to be a valid callback, class xxx not found

有谁有主意吗?

EN

回答 1

WordPress Development用户

发布于 2022-06-30 09:47:19

这就是我问题的解决办法。

代码语言:javascript
复制
    add_action('customize_register', function ($wp_customize) {
        $wp_customize->add_section('copyright_extras_section', array(
            'title'          => 'Copyright Text Section'
        ));
    
        //adding setting for copyright text
        $wp_customize->add_setting('text_setting', array(
            'default'        => 'Default Text For copyright Section',
        ));
    
        $wp_customize->add_control('text_setting', array(
            'label'   => 'Copyright text',
            'section' => 'copyright_extras_section',
            'type'    => 'text',
        ));
    });
票数 0
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/407230

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档