2017-11-02 6 views
0

ショップのアーカイブページに商品の全情報(抜粋、写真、タイトル、価格など)を記載したすべての商品を含むWoocommerceショップを構築しようとしています。商品詳細ページはありません。店舗アーカイブページでWoocommerceイメージギャラリーの機能を有効にする

my-theme/woocommerceフォルダのカスタムarchive-product.phpのループに、ページコンテンツではなく単純なページコンテンツを読み込んでいます。

私の問題は、製品画像ギャラリーの機能(ズーム、ライトボックス、スライダー)がアーカイブページでは機能しないことです。単一製品ページでのみ機能します。

ショップやカテゴリのアーカイブページのギャラリー機能を解除するにはどうすればよいですか?

私は、WordPressまたはwoocommerceがこのページのギャラリー機能の特定のjavascriptまたはphp関数を何とか無効にしたと思います。しかし、私はどこに変更を加えて戻すことができないのか分かりませんでした。

ここで私はmoded archive-product.phpのループに使用するコードです。私は単純に、完全な製品コンテンツをロードするために「一製品」に「製品」を変更:

<?php while (have_posts()) : the_post(); ?> 

    <?php 
     /** 
     * woocommerce_shop_loop hook. 
     * 
     * @hooked WC_Structured_Data::generate_product_data() - 10 
     */ 
    do_action('woocommerce_shop_loop'); 
    ?> 

    <!-- This part of the template has been moded for the product archive page to show the complete content of the single product page --> 

    <?php wc_get_template_part('content', 'single-product'); ?> 

<?php endwhile; // end of the loop. ?> 
+1

https://stackoverflow.com/help/how-to-askをお読みください。問題をより明確に記述し、外部リンクを避けてください。 – Doomenik

+0

ok私はそれを更新し、いくつかのコードを挿入しました。今は大丈夫ですか? – jolo

答えて

0

誰が今まで私と同じ問題を抱えているし、アーカイブにwoocommerceの画像ギャラリー機能を有効にしたい場合あなたのテーマフォルダ内のfunctions.phpにこのコードを追加してください:

add_action('wp_enqueue_scripts', 'gallery_scripts', 20); 

function gallery_scripts() { 
    if (is_archive()) { 
     if (current_theme_supports('wc-product-gallery-zoom')) { 
      wp_enqueue_script('zoom'); 
     } 
     if (current_theme_supports('wc-product-gallery-slider')) { 
      wp_enqueue_script('flexslider'); 
     } 
     if (current_theme_supports('wc-product-gallery-lightbox')) { 
      wp_enqueue_script('photoswipe-ui-default'); 
      wp_enqueue_style('photoswipe-default-skin'); 
      add_action('wp_footer', 'woocommerce_photoswipe'); 
     } 
     wp_enqueue_script('wc-single-product'); 
    } 

} 
関連する問題