我正在学习如何在WordPress中创建徽标上传器,以便我可以使用定制器将自己的徽标上传到我的WordPress网站。
警告:call_user_func_array() 期望参数 1 是有效的回调,找不到函数 'wpt_register_theme_customizer' 或无效的函数名称在/Users/brandonpowell/sites/vanlet/wordpress-development/web/wp/wp-include/class-wp-hook.php 第 298 行我
正在运行在每个教程和博客文章中发布如何创建徽标上传我每次都会遇到相同的错误消息。有人可以向我解释创建徽标上传器的最佳方法吗?
function wpt_register_theme_customizer( $wp_customize ) {
// Add Custom Logo Settings
$wp_customize->add_section( 'custom_logo' , array(
'title' => __('Change Your Logo','wptthemecustomizer'),
'panel' => 'design_settings',
'priority' => 20
) );
$wp_customize->add_setting(
'wpt_logo',
array(
'default' => get_template_directory_uri() . '/images/logo.png',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
new My_Customize_Image_Reloaded_Control(
$wp_customize,
'custom_logo',
array(
'label' => __( 'Change Logo', 'wptthemecustomizer' ),
'section' => 'custom_logo',
'settings' => 'wpt_logo',
'context' => 'wpt-custom-logo'
)
)
);
}
add_action( 'customize_register', 'wpt_register_theme_customizer' );
您是否在此文件中使用了namespace
?如果是这样,您需要在函数名称中包含命名空间,如下所示:
add_action( 'customize_register', __NAMESPACE__ . '\wpt_register_theme_customizer' );