2014-11-14 83 views
0

我開發wordpress主題目錄的wordpress主題。在這個主題中,我已經通過這個波紋管在functions.php的如何獲得wp自定義標題圖像的條件?

$defaults = array(
'width'   => 1600, 
'height'  => 400, 
'flex-height' => false, 
'flex-width' => false, 
'default-image' => get_template_directory_uri() . '/images/lemon.jpg', 
'uploads'  => true, 
'default-text-color' => '95b849', 
'header-text' => true, 
);  
add_theme_support('custom-header',$defaults); 

設置自定義標題圖片和我一樣顯示波紋管這個標題圖片:

<div class="header_top_image" style="background-image: url(<?php header_image(); ?>); background-color: #<?php echo get_header_textcolor();?>;"> 
<h1 class="header_top_title"> 
    <a style="color: #<?php echo get_header_textcolor();?>;" href="<?php echo esc_url(home_url('/')); ?>"> 
    <?php bloginfo('name'); ?> 
    </a> 
</h1> 
</div> 

在這種情況下,我想:如果不是設置Custom Header圖像,這個「header_top_image」類的div標籤完全不顯示。

我該怎麼做。其實我想,有一個功能:is_custome_header(), 即使我在codex上搜索。但是沒有找到像這樣提供條件的任何功能。 任何機構都可以幫助我?我非常需要這個解決方案。 高級謝謝

+1

因此,如果沒有設置'header_image()',那麼不顯示div?應該是一個簡單的解決方案,只是確認你問了什麼。 – Stewartside

+0

嘿@Stewartside,如果(header_image())不起作用 –

+0

其實我得到的解決方案︰if(get_header_image()) –

回答

0

其實現在我得到了解決方案。它會:

<?php 
if(get_header_image()){ ?> 
<div>Desired div/elements here</div> 
<?php } ?> 
相關問題