如何使用WordPress自定义更改图像($ wp_customize)?

时间:2022-12-02 19:18:21

I have the following code below, but I can't figure out why it's not working. All I get from my template is a blank screen. Any ideas? I'm using the latest version of WordPress.

我在下面有以下代码,但我无法弄清楚它为什么不起作用。我从模板中得到的只是一个空白屏幕。有任何想法吗?我正在使用最新版本的WordPress。

function twentyone_customizer_register($wp_customize)
{
    $wp_customize->add_section('logo_changer', array(
        'title'       => __('Images', 'twentyone'),
        'description' => 'Change index page background image.'
    ));

    $wp_customize->add_setting('logo_image', array(
        'default' => 'http://localhost/twentyone/wp-content/themes/twentyone/assets/img/showcase.jpg'
    ));

    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'logo_image', array(
        'label'    => __('Edit Showcase Image', 'twentyone'),
        'section'  => 'logo_changer',
        'settings' => 'logo_image'
    )));
}
add_action('customize_register', 'twentyone_customizer_register');

1 个解决方案

#1


0  

I've solved my problem and I have edited the code to reflect the changes. I named the function starting with a number and that caused the theme customizer not to work.

我已经解决了我的问题,并且编辑了代码以反映更改。我将函数命名为以数字开头,这导致主题定制器无法工作。

#1


0  

I've solved my problem and I have edited the code to reflect the changes. I named the function starting with a number and that caused the theme customizer not to work.

我已经解决了我的问题,并且编辑了代码以反映更改。我将函数命名为以数字开头,这导致主题定制器无法工作。