【问题标题】:WordPress Customizer Error: Call to a member function add_setting() on unknownWordPress 定制程序错误:调用未知的成员函数 add_setting()
【发布时间】:2017-09-07 04:10:25
【问题描述】:

我正在尝试通过 WordPress 中的定制器设置一个简单的标题。我是 PHP 和 WP 开发的新手。

这是我的functions.php:

//add contact_info_header customizer
function wpl_customize_register( $wp_register ) {
//ALL sections, settings and controls will be added
$wp_customizer->add_setting( 'contact_header', array(
    'default'   => 'Giver Uforpligtende Tilbud',
    'transport' => 'refresh'
    ) );


$wp_customize->add_control(
    new WP_Customize_Text_Control( $wp_customize, 'Contact Heading', array(
        'label'     => __( 'Contact Heading', 'lorrix_one_lite_child'),
        'section'   => 'llorix_one_lite_contact_section',
        'settings'  => 'contact_header',
        'type'      => 'text'
        ) ) );

$wp_customize->get_section ('llorix_one_lite_contact_section')->transport = 'refresh';
}
add_action( 'customize_register', 'wpl_customize_register');

还有我的错误代码。我在访问前端定制器时才得到这个:

"致命错误:未捕获错误:调用成员函数 add_setting() on C:\xampp\htdocs\localwp.com\wp-content\themes\llorix-one-lite-child\functions.php:20 中未知堆栈跟踪:#0 C:\xampp\htdocs\localwp.com\wp-包括\class-wp-hook.php(298): wpl_customize_register(Object(WP_Customize_Manager)) #1 C:\xampp\htdocs\localwp.com\wp-includes\class-wp-hook.php(323): WP_Hook- >apply_filters(NULL, Array) #2 C:\xampp\htdocs\localwp.com\wp-includes\plugin.php(453): WP_Hook->do_action(Array) #3 C:\xampp\htdocs\localwp.com \wp-includes\class-wp-customize-manager.php(734): do_action('customize_regis...', Object(WP_Customize_Manager)) #4 C:\xampp\htdocs\localwp.com\wp-includes\class -wp-hook.php(298): WP_Customize_Manager->wp_loaded('') #5 C:\xampp\htdocs\localwp.com\wp-includes\class-wp-hook.php(323): WP_Hook->apply_filters (NULL, 数组) #6 C:\xampp\htdocs\localwp.com\wp-includes\plugin.php(453): WP_Hook->do_action(Array) #7 C:\xampp\htdocs\localwp.com\wp -settings.php(470): do_action('wp_loaded') #8 C:\xampp\htdocs\localwp.com\wp-con 在 C:\xampp\htdocs\localwp.com\wp- content\themes\llorix-one-lite-child\functions.php 第 20 行"

在我看来,在 $wp_customize 对象上调用 add_setting() 时遇到问题?

感谢大家的阅读和回答。

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    解决了。在我试图编辑的 HTML 周围有一个不必要的函数...哎呀

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-27
      • 2014-11-13
      • 2021-05-07
      • 1970-01-01
      • 1970-01-01
      • 2018-09-10
      • 1970-01-01
      相关资源
      最近更新 更多