2017-02-08 3 views
0

내 카테고리 페이지에서 WooCommerce가 20 개 제품을 보여줍니다.WooCommerce의 제품 목록간에 div를 추가하는 방법은 무엇입니까?

제품 목록을 40 개로 늘리고 20 개 제품을 추가 한 다음 div를 추가하려고합니다.

아무도 도와 줄 수 있습니까? 여기

<?php 

if (! defined('ABSPATH')) { 
    exit; // Exit if accessed directly 
} 

get_header('shop'); ?> 

<?php 
    /** 
    * woocommerce_before_main_content hook. 
    * 
    * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content) 
    * @hooked woocommerce_breadcrumb - 20 
    */ 
    do_action('woocommerce_before_main_content'); 
?> 

    <?php if (apply_filters('woocommerce_show_page_title', false)) : ?> 

     <h1 class="page-title" style="display:none;"><?php woocommerce_page_title(); ?></h1> 

    <?php endif; ?> 

    <?php 
     /** 
     * woocommerce_archive_description hook. 
     * 
     * @hooked woocommerce_taxonomy_archive_description - 10 
     * @hooked woocommerce_product_archive_description - 10 
     */ 
     do_action('woocommerce_archive_description'); 
    ?> 

    <?php if (have_posts()) : ?> 

     <?php 
      /** 
      * woocommerce_before_shop_loop hook. 
      * 
      * @hooked woocommerce_result_count - 20 
      * @hooked woocommerce_catalog_ordering - 30 
      */ 
      do_action('woocommerce_before_shop_loop'); 
     ?> 


     <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12"> 
     <div class="content-box"> 
     <?php woocommerce_product_loop_start(); ?> 

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

      ?> 
       <?php if (is_search()) { ?> 
        <?php wc_get_template_part('content', 'search'); ?> 
       <?php }else{ ?> 
       <?php wc_get_template_part('content', 'product'); 
      } 



       ?> 


      <?php endwhile; // end of the loop. 

      ?> 

      <?php woocommerce_product_loop_end(); ?> 

     </div></div> 


     <?php 
      /** 
      * woocommerce_after_shop_loop hook. 
      * 
      * @hooked woocommerce_pagination - 10 
      */ 
      do_action('woocommerce_after_shop_loop'); 
     ?> 

    <?php elseif (! woocommerce_product_subcategories(array('before' => woocommerce_product_loop_start(false), 'after' => woocommerce_product_loop_end(false)))) : ?> 

     <?php wc_get_template('loop/no-products-found.php'); ?> 

    <?php endif; ?> 

<?php 
    /** 
    * woocommerce_after_main_content hook. 
    * 
    * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content) 
    */ 
    do_action('woocommerce_after_main_content'); 
?> 

<?php 
    /** 
    * woocommerce_sidebar hook. 
    * 
    * @hooked woocommerce_get_sidebar - 10 
    */ 
    do_action('woocommerce_sidebar'); 
?> 
다음

내 컨텐츠 product.php 코드

<?php 
/** 
* The template for displaying product content within loops 
* 
* This template can be overridden by copying it to yourtheme/woocommerce/content-product.php. 
* 
* HOWEVER, on occasion WooCommerce will need to update template files and you 
* (the theme developer) will need to copy the new files to your theme to 
* maintain compatibility. We try to do this as little as possible, but it does 
* happen. When this occurs the version of the template file will be bumped and 
* the readme will list any important changes. 
* 
* @see  https://docs.woocommerce.com/document/template-structure/ 
* @author WooThemes 
* @package WooCommerce/Templates 
* @version 2.6.1 
*/ 

if (! defined('ABSPATH')) { 
    exit; // Exit if accessed directly 
} 

global $product; 

// Ensure visibility 
if (empty($product) || ! $product->is_visible()) { 
    return; 
} 
?> 

<?php 
/** 
* woocommerce_before_shop_loop_item hook. 
* 
* @hooked woocommerce_template_loop_product_link_open - 10 
*/ 
do_action('woocommerce_before_shop_loop_item'); 

/** 
* woocommerce_before_shop_loop_item_title hook. 
* 
* @hooked woocommerce_show_product_loop_sale_flash - 10 
* @hooked woocommerce_template_loop_product_thumbnail - 10 
*/ 
do_action('woocommerce_before_shop_loop_item_title'); 

/** 
* woocommerce_shop_loop_item_title hook. 
* 
* @hooked woocommerce_template_loop_product_title - 10 
*/ 
//do_action('woocommerce_shop_loop_item_title');?> 

<tr <?php post_class(); ?>> 
    <td class="slno"> 
    </td> 
<td><?php do_action('woocommerce_shop_loop_item_title'); ?></td> 
<td class="des"> 
    <?php do_action('woocommerce_after_shop_loop_item'); ?> 
?>

답변

0

추가 내 아카이브 - product.php 코드 이 테마 또는 사용자 정의 플러그인의 function.php 페이지 당 제품을 증가시키는 : 여기

add_filter('loop_shop_per_page', create_function('$cols', 'return 40;'), 20); 

는 \ "의 WP-내용 \ 플러그인 \ woocommerce \ 템플릿 \ 아카이브 - product.php"에 대한 샘플 당신의 경우 직접 코어를 편집하거나 templates 디렉토리를 현재 테마 디렉토리에 복사하여 덮어 쓰면 경로는 "\ mytheme \ woocommerce \ archive-product.php"가됩니다.

archive-product.php의 내용을 정확하게 확인하십시오 위/아래 바로 아래

<?php 
/** 
* The Template for displaying product archives, including the main shop page which is a post type archive 
* 
* This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php. 
* 
* HOWEVER, on occasion WooCommerce will need to update template files and you 
* (the theme developer) will need to copy the new files to your theme to 
* maintain compatibility. We try to do this as little as possible, but it does 
* happen. When this occurs the version of the template file will be bumped and 
* the readme will list any important changes. 
* 
* @see   https://docs.woocommerce.com/document/template-structure/ 
* @author  WooThemes 
* @package  WooCommerce/Templates 
* @version  2.0.0 
*/ 

if (! defined('ABSPATH')) { 
    exit; // Exit if accessed directly 
} 

get_header('shop'); ?> 
<?php 
    /** 
    * woocommerce_before_main_content hook. 
    * 
    * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content) 
    * @hooked woocommerce_breadcrumb - 20 
    */ 
    do_action('woocommerce_before_main_content'); 
?> 

    <?php if (apply_filters('woocommerce_show_page_title', true)) : ?> 

     <h1 class="page-title"><?php woocommerce_page_title(); ?></h1> 

    <?php endif; ?> 

    <?php 
     /** 
     * woocommerce_archive_description hook. 
     * 
     * @hooked woocommerce_taxonomy_archive_description - 10 
     * @hooked woocommerce_product_archive_description - 10 
     */ 
     do_action('woocommerce_archive_description'); 
    ?> 

    <?php if (have_posts()) : ?> 

     <?php 
      /** 
      * woocommerce_before_shop_loop hook. 
      * 
      * @hooked woocommerce_result_count - 20 
      * @hooked woocommerce_catalog_ordering - 30 
      */ 
      do_action('woocommerce_before_shop_loop'); 
     ?> 

     <?php woocommerce_product_loop_start(); ?> 

      <?php woocommerce_product_subcategories(); ?> 
          <?php $productIndex = 0; $addDivAt = 20 ?> 
      <?php while (have_posts()) : the_post(); ?> 

       <?php wc_get_template_part('content', 'product'); ?> 
        <?php $productIndex++; ?> 
        <?php if($productIndex == $addDivAt): ?> 
        <div>TRUE</div> 
        <?php endif; ?> 

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

     <?php woocommerce_product_loop_end(); ?> 

     <?php 
      /** 
      * woocommerce_after_shop_loop hook. 
      * 
      * @hooked woocommerce_pagination - 10 
      */ 
      do_action('woocommerce_after_shop_loop'); 
     ?> 

    <?php elseif (! woocommerce_product_subcategories(array('before' => woocommerce_product_loop_start(false), 'after' => woocommerce_product_loop_end(false)))) : ?> 

     <?php wc_get_template('loop/no-products-found.php'); ?> 

    <?php endif; ?> 

<?php 
    /** 
    * woocommerce_after_main_content hook. 
    * 
    * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content) 
    */ 
    do_action('woocommerce_after_main_content'); 
?> 

<?php 
    /** 
    * woocommerce_sidebar hook. 
    * 
    * @hooked woocommerce_get_sidebar - 10 
    */ 
    do_action('woocommerce_sidebar'); 
?> 
+0

어떻게 20 번째 제품 이후에 콘텐츠가 포함 된 div를 삽입 할 수 있습니까? @gvgvgvijayan – Lipsa

+0

@Lipsa archive-product.php에 대한 내용을 'while (have_posts()) : the_post(); 바로 위와 아래에서 확인하십시오. – gvgvgvijayan

+0

내 아카이브에서 변경된 내용이 궁금합니다. -product.php가 프런트 엔드에 반영되지 않습니다 ... 그러나 제품 목록이 있습니다 ... – Lipsa

관련 문제