WordPress the_custom_logo在主页上没有链接



我使用的是二十一儿童主题,我想将custom_logo链接到主页,即使是在主页上。

但我找不到任何设置?

我读到:https://developer.wordpress.org/reference/functions/the_custom_logo/

上面写着:";显示链接到主页的自定义徽标,除非主题支持删除主页上的链接";

但如果我查看父主题的site-branding.php,我只能找到以下内容:

<?php if ( has_custom_logo() && $show_title ) : ?>
<div class="site-logo"><?php the_custom_logo(); ?></div>
<?php endif; ?>
<div class="site-branding">
<?php if ( has_custom_logo() && ! $show_title ) : ?>
<div class="site-logo"><?php the_custom_logo(); ?></div>
<?php endif; ?>

没有如果/其他链接或不链接它。

我该怎么做?

这是因为父主题的函数中有这段代码。hp:

add_theme_support(
'custom-logo',
array(
'height'               => $logo_height,
'width'                => $logo_width,
'flex-width'           => true,
'flex-height'          => true,
'unlink-homepage-logo' => true,
)
);

在您的子主题的functions.php中,您可以删除主题支持,然后再次将其添加回来,您可以这样做:

remove_theme_support( 'custom-logo' );
$logo_width  = 300;
$logo_height = 100;
add_theme_support(
'custom-logo',
array(
'height'               => $logo_height,
'width'                => $logo_width,
'flex-width'           => true,
'flex-height'          => true,
'unlink-homepage-logo' => false,
)
);

UPDATE:您必须将此代码添加到操作中,而不是直接在functions.php中使用它。

最新更新