WordPress.org

Make WordPress Core

Ticket #37011: 37011.1.diff

File 37011.1.diff, 1.2 KB (added by audrasjb, 16 months ago)

If on home/front page, don’t link the logo to home

  • src/wp-includes/general-template.php

    diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php
    index 897e28b3c9..4ed359c770 100644
    a b function get_custom_logo( $blog_id = 0 ) { 
    976976                 * If the alt attribute is not empty, there's no need to explicitly pass
    977977                 * it because wp_get_attachment_image() already adds the alt attribute.
    978978                 */
    979                 $html = sprintf(
    980                         '<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
    981                         esc_url( home_url( '/' ) ),
    982                         wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
    983                 );
     979                if ( is_home() || is_front_page() ) {
     980                        // If on the home or front page, don’t link the logo to home.
     981                        $html = wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr );
     982                } else {
     983                        $html = sprintf(
     984                                '<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
     985                                esc_url( home_url( '/' ) ),
     986                                wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
     987                        );
     988                }
    984989        } elseif ( is_customize_preview() ) {
    985990                // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
    986991                $html = sprintf(