我正在尝试为定制程序添加第二个徽标选项。php的父主题使用函数。来自子主题的php。但是,我得到一个500内部服务器错误。我做错了什么?
这是自定义程序的代码。php文件位于父主题的“extend”文件夹中。
function j007_customize_register( $wp_customize ) {
/* Logo */
$wp_customize->add_setting( \'logo\', array(
\'type\' => \'theme_mod\', // or \'option\'
\'capability\' => \'edit_theme_options\',
\'theme_supports\' => \'\', // Rarely needed.
\'default\' => \'\',
\'transport\' => \'refresh\', // or postMessage
\'sanitize_callback\' => \'j007_fun_sanitize_callback\' // Get function name
) );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, \'logo\', array(
\'label\' => esc_html__( \'Logo\', \'em4u\' ),
\'section\' => \'header_section\',
\'settings\' => \'logo\'
)));
}
function j007_fun_sanitize_callback($value){
return $value;
}
add_action( \'customize_register\', \'j007_customize_register\' );
这是我在函数上使用的代码。子主题的php
// Add alternative logo
function j007_customize_register( $wp_customize )
{
$wp_customize->add_setting( \'logo_alt\', array(
\'type\' => \'theme_mod\', // or \'option\'
\'capability\' => \'edit_theme_options\',
\'theme_supports\' => \'\', // Rarely needed.
\'default\' => \'\',
\'transport\' => \'refresh\', // or postMessage
\'sanitize_callback\' => \'j007_fun_sanitize_callback\' // Get function name
) );
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
\'logo_alt\',
array(
\'label\' => esc_html__( \'Logo\', \'j007\' ),
\'section\' => \'header_section\',
\'settings\' => \'logo_alt\'
)
)
);
}
add_action( \'customize_register\', \'j007_customize_register\' );
最合适的回答,由SO网友:Jignesh Patel 整理而成
将此代码置于函数中。php。在customizer中为徽标创建自定义部分:
<?php
add_action(\'customize_register\', \'theme_footer_customizer\');
function theme_footer_customizer($wp_customize){
//adding section in wordpress customizer
$wp_customize->add_section(\'footer_settings_section\', array(
\'title\' => \'Footer Text Section\'
));
//adding setting for footer logo
$wp_customize->add_setting(\'footer_logo\');
$wp_customize->add_control(new WP_Customize_Upload_Control($wp_customize,\'footer_logo\',array(
\'label\' => \'Footer Logo\',
\'section\' => \'footer_settings_section\',
\'settings\' => \'footer_logo\',
)));
}