2016-12-28 10 views
1

Genesisフレームワークを使用してサイトを構築しています。私は各ページにカスタムヘッダーを追加し、管理領域におすすめ画像リンクを使用して投稿するという問題に遭遇しました。今、「読書」設定の下にある「ブログ」ページに割り当てられたページには、おすすめ画像のヘッダーは表示されません。Wordpress Genesisテーマは、特色画像を使用してカスタムヘッダー/背景画像を表示します。

ここにサイトのURL、http://ajcustomfinishes.starfireclients.com/があります。

ここで私が使用しています機能があります:

// Create new image size for our hero image 
add_image_size('hero-image', 1400, 400, TRUE); // creates a hero image size 

// Hook after header area 
add_action('genesis_after_header', 'bw_hero_image'); 

function bw_hero_image() { 
// If it is a page and has a featured thumbnail, but is not the front page do the following... 
    if (has_post_thumbnail() && is_page()) { 
     // Get hero image and save in variable called $background 
     $image_desktop = wp_get_attachment_image_src(get_post_thumbnail_id($page->ID), 'hero-image'); 
     $image_tablet = wp_get_attachment_image_src(get_post_thumbnail_id($page->ID), 'large'); 
     $image_mobile = wp_get_attachment_image_src(get_post_thumbnail_id($page->ID), 'medium'); 

     $bgdesktop = $image_desktop[0]; 
     $bgtablet = $image_tablet[0]; 
     $bgmobile = $image_mobile[0]; 

// You can change above-post-hero to any class you want and adjust CSS styles 
     $featured_class = 'above-post-hero'; 

?> 
<div class='<?php echo $featured_class; ?>'><h1 class="custom-title">AJ Customs Finishes in Las Vegas<br>Call 702-795-7338 today!</h1></div> 
<style> 
    <?php echo ".$featured_class "; ?> {background-image:url(<?php echo $bgmobile; ?>);height:176px;} 

     @media only screen and (min-width : 480px) {  
     <?php echo ".$featured_class "; ?> {background-image:url(<?php echo $bgtablet;?>);height:276px;} 
     } 
     @media only screen and (min-width : 992px) {  
     <?php echo ".$featured_class "; ?> {background-image:url(<?php echo $bgdesktop;?>);height:400px;} 
     } 
</style> 
<?php 
    } 
} 

は、誰もが、私は各ページのカスタムヘッダーを表示する機能を備えた画像を使用することができる方法を知っていますか?

if (has_post_thumbnail() && is_page()) { 

is_page()ブログの記事ホーム(あなたが設定ページではfalseになります。

答えて

0

あなたが読書の設定でブログとして設定されたページの場合はFALSEになりますあなたのコード内でこの状態を、持っています読書の記事)。

あなたはつまり、あなたがあることをあなたのコードを再利用することができます真である)is_home(この条件を設定する必要があります。感謝

if (has_post_thumbnail() && is_page() || is_home()) { 
+0

。魅力のように動作します。 –

関連する問題