I assume you have problem with google validator about itemprop="logo"
. You can hook into the get_custom_header
filter and alter the HTML structure:
add_filter( 'get_custom_logo', 'my_custom_logo' );
// Filter the output of logo to fix Googles Error about itemprop logo
function my_custom_logo() {
$custom_logo_id = get_theme_mod( 'custom_logo' );
$html = sprintf( '<a href="https://wordpress.stackexchange.com/questions/269388/%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
esc_url( home_url( "https://wordpress.stackexchange.com/" ) ),
wp_get_attachment_image( $custom_logo_id, 'full', false, array(
'class' => 'custom-logo',
) )
);
return $html;
}
Add the above code to your theme’s functions.php
or follow the steps here to create a child theme and use this code in it’s functions.php
file.
Edit
Based on @birgire’s comment, i wrote another function to filter the wp_get_attachment_image()
:
add_filter('wp_get_attachment_image', function ($attachment_id, $size , $icon , $attr) {
// If the class is 'custom-logo', then change the itemprop to image
if ($attr['class'] =='custom-logo') {
$attr['itemprop'] = 'image';
}
return $attr;
},10,3);