我想你对google validator有问题itemprop="logo"
. 你可以在get_custom_header
过滤并更改HTML结构:
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="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>\',
esc_url( home_url( \'/\' ) ),
wp_get_attachment_image( $custom_logo_id, \'full\', false, array(
\'class\' => \'custom-logo\',
) )
);
return $html;
}
将上述代码添加到主题的
functions.php
或者按照以下步骤操作
here 创建子主题并在其
functions.php
文件
编辑根据@birgire的评论,我编写了另一个函数来过滤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);