The generate_logo_output
filter allows us to alter the HTML of our logo.
Examples
If we want to add a new class to our logo container:
add_filter( 'generate_logo_output', 'tu_logo_class', 10, 3 ); function tu_logo_class( $output, $logo_url, $html_attr ) { printf( '<div class="site-logo MY-CUSTOM-CLASS"> <a href="%1$s" title="%2$s" rel="home"> <img %3$s /> </a> </div>', esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), $html_attr ); }
If we want our logo to open in a new window:
add_filter( 'generate_logo_output', 'tu_logo_target', 10, 3 ); function tu_logo_target( $output, $logo_url, $html_attr ) { printf( '<div class="site-logo"> <a href="%1$s" title="%2$s" rel="home" target="_blank" rel="noopener"> <img %3$s /> </a> </div>', esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), $html_attr ); }
If we don’t want a link surrounding our logo:
add_filter( 'generate_logo_output', 'tu_no_logo_link', 10, 3 ); function tu_no_logo_link( $output, $logo_url, $html_attr ) { printf( '<div class="site-logo"> <img %1$s /> </div>', $html_attr ); }