Wordpress自定义小工具logo调用设置(可视化)

在主题开发中,需要调用网站的logo,最简单的办法就是用wp自带的函数,那就是the_custom_logo(),使用它还可以通过后台-自定义-logo,边修改边预览,还是很香的。

        自定义徽标支持应首先使用add_theme_support()添加到主题中,然后使用the_custom_logo()在主题中调用

直接上代码:

1.在functions.php中 ,添加

// 自定义logo 在需要位置调用 the_custom_logo() 
    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.在需要位置调用

<?php the_custom_logo() ?>

修改上传logo的方法:后台——外观——自定义——logo

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值