在主题开发中,希望可以让用户自定义logo,允许用户修改logo,怎么设置?看教程:

1.在functions.php中添加以下代码:

function themename_custom_logo_setup() {
        $defaults = array(
            'height'      => 100,
            'width'       => 400,
            'flex-height' => true,
            'flex-width'  => true,
            'header-text' => array( 'site-title', 'site-description' ),
        );
        add_theme_support( 'custom-logo', $defaults );
 }
 add_action( 'after_setup_theme', 'themename_custom_logo_setup' );

2.在header或者自己需要的地方直接用函数调用

调用公式:

<?php the_custom_logo() ?>