the_custom_logo()

the_custom_logo() imprime el logo del sitio que el usuario ha configurado desde Apariencia → Personalizar → Identidad del sitio. Para que funcione, el tema debe declarar soporte con add_theme_support('custom-logo').

Activar el soporte en el tema

add_action( 'after_setup_theme', 'mi_tema_setup' );
function mi_tema_setup() {
    add_theme_support( 'custom-logo', [
        'height'               => 80,    // altura recomendada en px
        'width'                => 200,   // anchura recomendada en px
        'flex-height'          => true,  // permite alturas distintas
        'flex-width'           => true,  // permite anchuras distintas
        'header-text'          => [ 'site-title', 'site-description' ],
        'unlink-homepage-logo' => true,  // sin enlace en la portada (WP 5.9+)
    ]);
}

Mostrar el logo en la plantilla

<!-- Forma simple -->
<?php the_custom_logo(); ?>

<!-- HTML que genera -->
<a href="https://tusitio.com" class="custom-logo-link" rel="home">
    <img src="/wp-content/uploads/logo.png" class="custom-logo" alt="Mi Sitio">
</a>

Con fallback al nombre del sitio

<div class="site-branding">
    <?php if ( has_custom_logo() ) : ?>
        <?php the_custom_logo(); ?>
    <?php else : ?>
        <p class="site-title">
            <a href="<?php echo esc_url( home_url('/') ); ?>">
                <?php bloginfo('name'); ?>
            </a>
        </p>
    <?php endif; ?>
</div>

Obtener la URL del logo

// Para usar la URL en img src o background-image
$logo_id  = get_theme_mod( 'custom_logo' );
$logo_url = wp_get_attachment_image_url( $logo_id, 'full' );
echo '<img src="' . esc_url( $logo_url ) . '" alt="Logo">';