[英]Wordpress custom theme - I am unable to display the logowith this code
我正在制作自定義 wordpress 主題,但無法正確顯示徽標。 我正在使用此代碼顯示“the_custom_logo”,但未顯示徽標。 我添加了主題支持並上傳了徽標圖像。
<div class="brand">
<?php
if(function_exists('the_custom_logo')){
$custom_logo_id = get_theme_mod('custom-logo');
$logo = wp_get_attachment_image_src($custom_logo_id);
}
?>
<img src="<?php echo $logo[0] ?>" class="logo" alt="">
</div>
但是,當我嘗試以下代碼時,我能夠獲得徽標。 但它添加了我不想要的所有 wordpress 生成的類。 因此,我試圖使用上面的代碼。
<div class="brand">
<?php
if(function_exists('the_custom_logo')){
the_custom_logo();
}
?>
</div>
你可以試試這個。 ID 應該是下划線“custom_logo”
<div class="brand">
<?php
if(function_exists('the_custom_logo')){
$custom_logo_id = get_theme_mod( 'custom_logo' );
$logo = wp_get_attachment_image_src($custom_logo_id);
}
?>
<img src="<?php echo $logo[0] ?>" class="logo" alt="">
</div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.