Question

I have this in the functions.php:

add_theme_support( 'custom-logo', array(
        'height'      => 200,
        'width'       => 1000,
        'flex-width'  => true,
        'flex-height' => true,
    ) );

and this in my header file:

<div class="site-branding">
        <?php
        the_custom_logo();
        if ( is_front_page() || is_home() ) : ?>
            <h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
        <?php else : ?>
            <p class="site-title"><?php bloginfo( 'name' ); ?></p>
        <?php
        endif;

        $description = get_bloginfo( 'description', 'display' );
        if ( $description || is_customize_preview() ) : ?>
            <p class="site-description"><?php echo $description; /* WPCS: xss ok. */ ?></p>
        <?php
        endif; ?>
    </div>

The logo links to my home page, and I don't know why. What's causing it to do that? There's no a tag surrounding it. How can I make the logo NOT a link?

Was it helpful?

Solution

Look at the documentation for the_custom_logo():

Displays a custom logo, linked to home.

So it's doing what it's supposed to.

If you want to do anything other than that, you can get the ID of the logo image using get_theme_mod( 'custom_logo' ). Then you can do whatever you want to it, such as just outputting the image:

echo wp_get_attachment_image( get_theme_mod( 'custom_logo' ), 'full' )
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top