我正在添加架构。组织标记到我的主题的标题,但我使用的主题正在调用the_custom_logo();
, 默认情况下,它使用“logo”作为itemprop
.
是否要将此更改为image
在functions.php
文件
谢谢
这是函数中的当前调用函数。php文件。
add_theme_support(\'custom-logo\');
我正在添加架构。组织标记到我的主题的标题,但我使用的主题正在调用the_custom_logo();
, 默认情况下,它使用“logo”作为itemprop
.
是否要将此更改为image
在functions.php
文件
谢谢
这是函数中的当前调用函数。php文件。
add_theme_support(\'custom-logo\');
我想你对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
文件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);
我在WordPress存储库中遇到了一个非常奇怪的行为,或者我做错了什么(更有可能)。因此,对于我在WordPress存储库中注册的插件,我创建了一个徽标,并将其上传为icon-128x128.png 以及icon-256x256.png 在/assets/-文件夹首先,我只上传了一个小徽标,它没有出现在搜索结果中。我想,我等了一会儿,因为存储库有时需要一些时间来做出反应。在这个徽标没有出现之后,我决定也许我也应该上传更大的256px徽标。所以我做到了。从那时起,这个标志就出现在WordPress管理员的