0

我正在使用WooCommerce 2.1.3自定義主題。自定義主題從頁面抓取'精選圖像',並用它來展開和顯示標題圖像(一些jQuery的東西)。要點是,WooCommerce使用「產品圖片」而不是「特色圖片」。我假設這就是爲什麼我的主題沒有選擇照片並將其用於標題圖像....標題保持空白。無論如何,將這個「特色圖像」添加回產品?這樣,它們與常規頁面相似。WooCommerce產品有'產品圖像',但沒有'精選圖像'

謝謝!

更新:

這是也包含jQuery的PHP文件。該文件稱爲頁面標題,progression.php

<?php if(is_404()): ?> 
    <div id="page-title"> 
     <div class="width-container paged-title"> 
      <h1 class="page-title"><?php _e('404 Page Not Found ', 'progression'); ?></h1> 
     </div> 
     <div id="page-title-divider"></div> 
    </div><!-- #page-title --> 
    <div class="clearfix"></div> 
    <?php $page_for_posts = get_option('page_for_posts'); ?> 
    <?php if(has_post_thumbnail($page_for_posts)): ?> 
     <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?> 
     <script type='text/javascript'> 

     jQuery(document).ready(function($) { 
      $("#page-title").backstretch([ 
       "<?php echo $image[0]; ?>" 
       <?php if(class_exists('kdMultipleFeaturedImages')) { 
        if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") { 
         echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"'; 
        } 

        if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") { 
         echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"'; 
        } 
       } 
       ?> 
      ],{ 
        fade: 750, 
        duration: <?php echo of_get_option('slider_autoplay', 8000); ?> 
      }); 
     }); 

     </script> 
    <?php endif; ?> 
<?php else: ?> 

    <?php if(is_page()): ?> 
     <?php 
     global $wp_query; 
     $thePostID = $wp_query->post->ID; 
     ?> 
     <div id="page-title"> 
      <div class="width-container paged-title"> 
       <h1><?php the_title(); ?></h1> 
      </div> 
     <div id="page-title-divider"></div> 
     </div><!-- #page-title --> 
     <div class="clearfix"></div> 
     <?php if(has_post_thumbnail()): ?> 
      <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'progression-page-title'); ?> 
      <script type='text/javascript'> 
      jQuery(document).ready(function($) { 
       $("#page-title").backstretch([ 
        "<?php echo $image[0]; ?>" 
        <?php if(class_exists('kdMultipleFeaturedImages')) { 
         if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") { 
          echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"'; 
         } 

         if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") { 
          echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"'; 
         } 
        } 
        ?> 
       ],{ 
         fade: 750, 
         duration: <?php echo of_get_option('slider_autoplay', 8000); ?> 
       }); 
      }); 
      </script> 
     <?php endif; ?> 
    <?php endif; ?> 

    <?php if(is_home() || is_single() && 'portfolio' != get_post_type() && 'menu' != get_post_type()): ?> 
     <div id="page-title"> 
      <div class="width-container paged-title"> 
       <?php $page_for_posts = get_option('page_for_posts'); ?> 
       <h1 class="page-title"><?php echo get_the_title($page_for_posts); ?></h1> 
      </div> 
     <div id="page-title-divider"></div> 
     </div><!-- #page-title --> 
     <div class="clearfix"></div> 
     <?php if(has_post_thumbnail($page_for_posts)): ?> 
      <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?> 
      <script type='text/javascript'> 

      jQuery(document).ready(function($) { 
       $("#page-title").backstretch([ 
        "<?php echo $image[0]; ?>" 
        <?php if(class_exists('kdMultipleFeaturedImages')) { 
         if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") { 
          echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"'; 
         } 

         if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") { 
          echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"'; 
         } 
        } 
        ?> 
       ],{ 
         fade: 750, 
         duration: <?php echo of_get_option('slider_autoplay', 8000); ?> 
       }); 
      }); 

      </script> 
     <?php endif; ?> 
    <?php endif; ?> 

    <?php if(is_archive()): ?> 
     <div id="page-title"> 
      <div class="width-container paged-title"> 
       <h1 class="page-title"> 
        <?php if (is_day()) : ?> 
        <?php printf(__('Archives: %s', 'progression'), '<span>' . get_the_date() . '</span>'); ?> 
        <?php elseif (is_month()) : ?> 
         <?php printf(__('Archives: %s', 'progression'), '<span>' . get_the_date('F Y') . '</span>'); ?> 
        <?php elseif (is_year()) : ?> 
         <?php printf(__('Archives: %s', 'progression'), '<span>' . get_the_date('Y') . '</span>'); ?> 
        <?php endif; ?> 
        <?php if (is_tag()) : ?> 
         <?php 
          printf(__('Tag: %s', 'progression'), '<span>' . single_tag_title('', false) . '</span>'); 
         ?> 
        <?php endif; ?> 
        <?php if (is_author()) : ?> 
         <?php _e('Author Archives:', 'progression'); ?> 
         <?php $user_info = get_userdata(1); 
           echo '' . $user_info->display_name . "\n"; 
         ?> 
        <?php endif; ?> 
        <?php if(post_type_exists('menu')) : ?> 
         <?php 
          printf(__('%s', 'progression'), '<span>' . single_cat_title('', false) . '</span>'); 
         ?> 
        <?php endif; ?> 
        </h1> 
       </div> 
      <div id="page-title-divider"></div> 
     </div><!-- #page-title --> 
     <div class="clearfix"></div> 
     <?php $page_for_posts = get_option('page_for_posts'); ?> 
     <?php if(has_post_thumbnail($page_for_posts)): ?> 
      <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?> 
      <script type='text/javascript'> 

      jQuery(document).ready(function($) { 
       $("#page-title").backstretch([ 
        "<?php echo $image[0]; ?>" 
        <?php if(class_exists('kdMultipleFeaturedImages')) { 
         if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") { 
          echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"'; 
         } 

         if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") { 
          echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"'; 
         } 
        } 
        ?> 
       ],{ 
         fade: 750, 
         duration: <?php echo of_get_option('slider_autoplay', 8000); ?> 
       }); 
      }); 

      </script> 
     <?php endif; ?> 

    <?php endif; ?> 

    <?php if(is_search()): ?> 
     <div id="page-title"> 
      <div class="width-container paged-title"> 
       <h1 class="page-title"><?php printf(__('Search for: %s', 'progression'), '<span>' . get_search_query() . '</span>'); ?></h1></div> 
     <div id="page-title-divider"></div> 

     </div><!-- #page-title --> 
     <div class="clearfix"></div> 
     <?php $page_for_posts = get_option('page_for_posts'); ?> 
     <?php if(has_post_thumbnail($page_for_posts)): ?> 
      <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?> 
      <script type='text/javascript'> 

      jQuery(document).ready(function($) { 
       $("#page-title").backstretch([ 
        "<?php echo $image[0]; ?>" 
        <?php if(class_exists('kdMultipleFeaturedImages')) { 
         if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") { 
          echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"'; 
         } 

         if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") { 
          echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"'; 
         } 
        } 
        ?> 
       ],{ 
         fade: 750, 
         duration: <?php echo of_get_option('slider_autoplay', 8000); ?> 
       }); 
      }); 

      </script> 
     <?php endif; ?> 
    <?php endif; ?> 

    <?php if(is_single() && 'portfolio' == get_post_type()): ?> 
     <div id="page-title"> 
      <div class="width-container paged-title"> 
       <h1><?php the_title(); ?></h1> 
      </div> 
     <div id="page-title-divider"></div> 
     </div><!-- #page-title --> 
     <div class="clearfix"></div> 
     <?php $page_for_posts = get_option('page_for_posts'); ?> 
     <?php if(has_post_thumbnail($page_for_posts)): ?> 
      <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?> 
      <script type='text/javascript'> 

      jQuery(document).ready(function($) { 
       $("#page-title").backstretch([ 
        "<?php echo $image[0]; ?>" 
        <?php if(class_exists('kdMultipleFeaturedImages')) { 
         if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") { 
          echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"'; 
         } 

         if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") { 
          echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"'; 
         } 
        } 
        ?> 
       ],{ 
         fade: 750, 
         duration: <?php echo of_get_option('slider_autoplay', 8000); ?> 
       }); 
      }); 

      </script> 
     <?php endif; ?> 
    <?php endif; ?> 



    <?php if(is_single() && 'menu' == get_post_type()): ?> 
     <div id="page-title"> 
      <div class="width-container paged-title"> 
       <h1><?php the_title(); ?></h1> 
      </div> 
     <div id="page-title-divider"></div> 
     </div><!-- #page-title --> 
     <div class="clearfix"></div> 
     <?php $page_for_posts = get_option('page_for_posts'); ?> 
     <?php if(has_post_thumbnail($page_for_posts)): ?> 
      <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?> 
      <script type='text/javascript'> 

      jQuery(document).ready(function($) { 
       $("#page-title").backstretch([ 
        "<?php echo $image[0]; ?>" 
        <?php if(class_exists('kdMultipleFeaturedImages')) { 
         if(kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) != "") { 
          echo ',"', kd_mfi_get_featured_image_url('featured-image-2', 'page', 'progression-page-title', $thePostID) , '"'; 
         } 

         if(kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) != "") { 
          echo ',"', kd_mfi_get_featured_image_url('featured-image-3', 'page', 'progression-page-title', $thePostID) , '"'; 
         } 
        } 
        ?> 
       ],{ 
         fade: 750, 
         duration: <?php echo of_get_option('slider_autoplay', 8000); ?> 
       }); 
      }); 

      </script> 
     <?php endif; ?> 
    <?php endif; ?> 

<?php endif; ?> 
+0

WooCommerce仍然使用功能的圖像和變化只是在界面上的「產品文圖片。」你能發表你正在使用的查詢代碼嗎? –

+0

我添加了上面的代碼。它適用於其他地方,但在產品頁面上。我甚至嘗試從我知道的模板(到單產品頁面,這是woocommerce用來顯示單個產品的頁面模板)複製PHP代碼,但它仍然不會顯示標題圖像。這讓我瘋狂。謝謝! – tmparisi

+0

我假設我需要添加一個新的if語句來識別產品頁面。這只是一個猜測。思考?如果這確實是正確的,那麼也許你可能知道如何進行if調用? – tmparisi

回答

0

只需要創建一個新的if語句的產品頁面:<?php if(is_product()): ?>

相關問題