the_custom_logo() - WordPress 函数参考中文文档

返回介绍

the_custom_logo()

发布于 2017-09-11 字数2343 浏览 918 评论 0

the_custom_logo( int $blog_id )

Displays a custom logo, linked to home.


描述


参数

$blog_id

(int)
(Optional)
ID of the blog in question. Default is the ID of the current blog.


源代码

File: wp-includes/general-template.php

function the_custom_logo( $blog_id = 0 ) {
	echo get_custom_logo( $blog_id );
}

更新日志

Version 描述
4.5.0 Introduced.

相关函数

Uses

  • wp-includes/general-template.php:
    get_custom_logo()

User Contributed Notes

  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 2You must log in to vote on the helpfulness of this note

    Contributed by Rami Yushuvaev

    To get the URL of the custom logo image:

    
    $custom_logo_id = get_theme_mod( 'custom_logo' );
    $image = wp_get_attachment_image_src( $custom_logo_id , 'full' );
    echo $image[0];
    
  2. See Also
    get_custom_logo()
    has_custom_logo()

    Add your custom logo to the login page:

    
    function wpdev_filter_login_head() {
    
    	if ( has_custom_logo() ) :
    
    		$image = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' );
    		?>
    		<style type="text/css">
    			.login h1 a {
    				background-image: url(<?php echo esc_url( $image[0] ); ?>);
    				-webkit-background-size: <?php echo absint( $image[1] )?>px;
    				background-size: <?php echo absint( $image[1] ) ?>px;
    				height: <?php echo absint( $image[2] ) ?>px;
    				width: <?php echo absint( $image[1] ) ?>px;
    			}
    		</style>
    		<?php
    	endif;
    }
    
    add_action( 'login_head', 'wpdev_filter_login_head', 100 );
    

上一篇:the_custom_header_markup()

下一篇:the_date()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!