the_custom_logo()WP 4.5.0

Displays a custom logo, linked to home.

No Hooks.

Return

null. Nothing (null).

Usage

the_custom_logo( $blog_id );
$blog_id(int)
ID of the blog in question.
Default: ID of the current blog

Examples

1

#1 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];

See Also:

0

#2 Display the site logo

<?php the_custom_logo( $blog_id ); ?>

/* Outputs this HTML code (one line only):

<a href="http://example.com/" class="custom-logo-link" rel="home" itemprop="url">
	<img 
	width="491" 
	height="299" 
	src="http://example.com/wp-content/uploads/2013/04/cropped-cropped-triforce-wallpaper.jpg" 
	class="custom-logo" 
	alt="cropped-cropped-triforce-wallpaper.jpg" 
	itemprop="logo" 
	srcset="http://example.com/wp-content/uploads/2013/04/cropped-cropped-triforce-wallpaper.jpg 491w, http://example.com/wp-content/uploads/2013/04/cropped-cropped-triforce-wallpaper-300x183.jpg 300w" 
	sizes="(max-width: 491px) 100vw, 491px" 
	/>
</a>
*/
0

#3 Get the logo, but without the link to the home page

$logo_img = '';
$custom_logo_id = get_theme_mod( 'custom_logo' );

if( $custom_logo_id ){
	$logo_img = wp_get_attachment_image( $custom_logo_id, 'full', false, array(
		'class'    => 'custom-logo',
		'itemprop' => 'logo',
	) );
}

echo $logo_img;
0

#4 Add your custom logo to the login page:

add_action( 'login_head', 'wpdev_filter_login_head', 100 );

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;
}

Remove the link to wordpress.org with your homepage link.

// Replace the link to wordpress.org with your homepage link.
add_filter( 'login_headerurl', 'new_wp_login_url');

function new_wp_login_url() {
	return home_url();
}

Changelog

Since 4.5.0 Introduced.

the_custom_logo() code WP 6.4.3

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