generate_logo_output

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, 2 );
function tu_logo_class( $output, $logo ) {
	printf( 
		'<div class="site-logo MY-CUSTOM-CLASS">
			<a href="%1$s" title="%2$s" rel="home">
				<img class="header-image" src="%3$s" alt="%2$s" title="%2$s" />
			</a>
		</div>',
		esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
		esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
		esc_url( apply_filters( 'generate_logo', $logo ) )
	);
}

If we want our logo to open in a new window:

add_filter( 'generate_logo_output','tu_logo_target', 10, 2 );
function tu_logo_target( $output, $logo ) {
	printf( 
		'<div class="site-logo">
			<a href="%1$s" title="%2$s" rel="home" target="_blank">
				<img class="header-image" src="%3$s" alt="%2$s" title="%2$s" />
			</a>
		</div>',
		esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
		esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
		esc_url( apply_filters( 'generate_logo', $logo ) )
	);
}

If we don’t want a link surrounding our logo:

add_filter( 'generate_logo_output','tu_no_logo_link', 10, 2 );
function tu_no_logo_link( $output, $logo ) {
	printf( 
		'<div class="site-logo">
			<img class="header-image" src="%2$s" alt="%1$s" title="%1$s" />
		</div>',
		esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
		esc_url( apply_filters( 'generate_logo', $logo ) )
	);
}