【问题标题】:Fatal error: Call to a member function check_capabilities() on a non-object致命错误:在非对象上调用成员函数 check_capabilities()
【发布时间】:2015-02-06 11:04:00
【问题描述】:

我在functions.php 中编写了这段代码,以便为我的主题个性化添加一个部分。 但是当我想打开“localhost/wordpress/wp-admin/customize.php?theme=eye-theme”来查看我的结果时,我看到了这个错误:

致命错误:在 C:\xampp\htdocs\xampp\wordpress\wp-includes\class-wp-customize-control.php 第 233 行的非对象上调用成员函数 check_capabilities()

这是我的functions.php

<?php

function eyetheme_register_theme_customizer($wp_customizer) {

    $wp_customizer->add_section(
        'eyetheme_display_options',
        array(
            'title'     => 'Display Options',
            'priority'  => 200
        )
    );

    $wp_customizer->add_setting(
        'eyetheme_link_color',
        array(
            'default'   => '#000000',
            'transport' => 'postMessage'
       )
    );

    $wp_customizer->add_control(
        'eyetheme_link_control',
        array(
            'section'   => 'eyetheme_display_options',
            'label'     => 'Link Color',
            'type'      => 'text'
       )
    );

}
add_action('customize_register', 'eyetheme_register_theme_customizer');

【问题讨论】:

    标签: php wordpress wordpress-theming


    【解决方案1】:

    您需要更新 $wp_customizer->add_setting() 方法和 $wp_customizer->add_control() 参数中的“设置”参数。

    即在你的例子中,

    $wp_customizer->add_setting( '链接颜色', 大批( '默认' => '#000', '运输' => 'postMessage' ) ); $wp_customizer->add_control( 'eyetheme_link_control', 大批( 'section' => 'eyetheme_display_options', '标签' => '链接颜色', '类型' => '文本', '设置' => 'link_color' ) )

    试试这个代码...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-25
      • 2012-05-30
      • 2016-08-30
      • 2012-05-14
      • 2013-11-19
      • 2017-04-30
      • 2015-04-13
      • 2014-10-22
      相关资源
      最近更新 更多