the_custom_logo()
Displays the HTML code of the site logo set in the theme settings. The code will be: <a href="https://wp-kama.ru/"><img></a>.
The logo can be set in the customizer or in the display settings:
This is a wrapper for the construct: echo get_custom_logo( $blog_id );
To be able to set the logo in the customizer, you need to enable support for custom-logo in the theme: add_theme_support( 'custom-logo' ).
Uses: get_custom_logo()
No Hooks.
Returns
null. Outputs the result on the screen. If the logo is not set in the theme settings, nothing will be output.
Usage
<?php the_custom_logo( $blog_id ); ?>
- $blog_id(number)
- ID of the site/blog whose logo needs to be retrieved.
Default: 0 (current blog)
Examples
#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:
#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> */
#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; #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() the custom logo code WP 6.9.1
function the_custom_logo( $blog_id = 0 ) {
echo get_custom_logo( $blog_id );
} 
