我在customizer中创建了一个图像控件。它显示字段,我可以上载/选择图像。但是,如果我发布并离开customizer,我可以看到它不会保存图像。我的所有文本/文本区域字段都工作正常。我使用下划线作为基本主题。
这是我的定制器中有问题的字段。php:
...
function minisite_customize_register( $wp_customize ) {
$wp_customize->get_setting( \'blogname\' )->transport = \'postMessage\';
$wp_customize->get_setting( \'blogdescription\' )->transport = \'postMessage\';
$wp_customize->get_setting( \'header_textcolor\' )->transport = \'postMessage\';
// Add Footer Logo Setting
$wp_customize->add_setting( \'footer_logo\',
array(
\'default\' => \'\',
\'transport\' => \'refresh\',
\'sanitize_callback\' => \'absint\'
)
);
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, \'footer_logo\',
array(
\'label\' => __( \'Footer Logo\' ),
\'description\' => esc_html__( \'Choose a footer logo.\' ),
\'section\' => \'title_tagline\',
)
) );
...
在我的页脚中。php我正在使用它进行测试(但当我返回到customizer时,我也可以看到空的图像字段):<?php
$footerlogo = get_theme_mod(\'footer_logo\');
if( !empty($footerlogo) )
{
echo \'yes\';
} else {
echo \'no\';
}
?>
我遵循本教程获取customizer中的图像字段:https://maddisondesigns.com/2017/05/the-wordpress-customizer-a-developers-guide-part-1#imagecontrol我错过什么了吗?