The generate_logo_output filter allows us to alter the HTML of our logo.
Setting a Width and Height
If want want to set a specific width and height in the logo HTML output:
add_filter( 'generate_logo_output','tu_logo_atts', 10, 2 );
function tu_logo_atts( $output, $logo ) {
printf(
'
',
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 ) )
);
}
Adding a New Class
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(
'
',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
$html_attr
);
}
Open a New Window
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(
'
',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
$html_attr
);
}
Remove the Logo Link
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(
'
',
$html_attr
);
}