提前感谢您的帮助调用成员函数check_capabilities()
在这个问题上陷入了困境!
目录布局:
- 的主题文件夹
- functions.php ('Theme'的主目录)
- index . php
- style.css
- 功能文件夹(位于"主题文件夹"内)
- customize.php
函数调用custom .php如下:
<?php require_once('functions/customize.php'); ?>
customize.php:
<?php
add_action('customize_register', 'adaptive_customize_register');
function adaptive_customize_register($wp_customize) {
//logo
$wp_customize->add_section('adaptive_logo', array(
'title' => __('Add Logo', 'adaptive_framework'),
'description' => __('Upload your main logo, this shows in the header', 'adaptive_framework'),
'priority' => '25'
));
$wp_customize->add_setting('adaptive_custom_settings[add_logo]', array(
'default' => 0,
'type' => 'option'
));
$wp_customize->add_control('adaptive_custom_settings[display_logo]', array(
'label' => __('Display logo?','adaptive_framework'),
'section' => 'adaptive_logo',
'settings' => 'adaptive_custom_settings[display_top_logo]',
'type' => 'checkbox'
));
}
?>
如果有人可以帮助,请,因为我得到错误如下:
Fatal error: Call to a member function check_capabilities() on a non-object in C:xampphtdocswordpresswp-includesclass-wp-customize-control.php on line 160
add_control()的settings参数必须与add_setting()中定义的设置名称相匹配。否则,控件将被添加到未知设置中,从而导致功能错误。
因此将adaptive_custom_settings[display_top_logo]
改为adaptive_custom_settings[add_logo]
<?php
add_action('customize_register', 'adaptive_customize_register');
function adaptive_customize_register($wp_customize) {
//logo
$wp_customize->add_section('adaptive_logo', array(
'title' => __('Add Logo', 'adaptive_framework'),
'description' => __('Upload your main logo, this shows in the header', 'adaptive_framework'),
'priority' => '25'
));
$wp_customize->add_setting('adaptive_custom_settings[add_logo]', array(
'default' => 0,
'type' => 'option'
));
$wp_customize->add_control('adaptive_custom_settings[display_logo]', array(
'label' => __('Display logo?','adaptive_framework'),
'section' => 'adaptive_logo',
'settings' => 'adaptive_custom_settings[add_logo]',
'type' => 'checkbox'
));
}
?>
不得不结束这个线程,因为我正在使用的代码现在不再需要,我将寻找得到完成的代码作为工作在一个例子在线。