woocommerce_product_loop将产品链接添加到页面的其他部分

时间:2019-06-10 12:10:52

标签: php wordpress loops woocommerce

我正在尝试创建一些自定义的Woocommerce页面,到目前为止一切进展顺利,但是使用“ woocommerce_product_loop”列出产品时遇到了问题。

该循环将循环中的第一个产品添加到页面的其他部分-我的循环位于带有“ store-content”类的div标签中,但是当检查页面时,我可以看到带有标签的13个实例产品的网址最不在包含div的位置-我也只有2个产品

如果我删除循环并刷新所有标签,则这些标记会消失,所以我知道这与循环有关

使用Wordpress 5.2.1–zh_CN Woocommerce 3.6.4

<div class="col-9">
 <div id="store-content" class="col-12">
  <?php 
  if ( woocommerce_product_loop() ) {
   do_action( 'woocommerce_before_shop_loop' );
   woocommerce_product_loop_start();
   if ( wc_get_loop_prop( 'total' ) ) {
    while ( have_posts() ) : the_post();
     do_action( 'woocommerce_shop_loop' );
     wc_get_template_part( 'content', 'product' );
    endwhile;
   };
   woocommerce_product_loop_end();
   do_action( 'woocommerce_after_shop_loop' );
   } else {
    do_action( 'woocommerce_no_products_found' );
  };  ?>
 </div>
</div>
(...)
<div class="col-9">
 <div id="store-content" class="col-12">
  <div class="columns-3">
   <div class="lmp_load_more_button br_lmp_prev_settings" style="display: none;">
    <a class="lmp_button btn btn-info" style="font-size: 22px;color: #ffffff;background-color: #17a2b8;padding-top:15px;padding-right:25px;padding-bottom:15px;padding-left:25px;margin-top:px;margin-right:px;margin-bottom:px;margin-left:px; border-top: 0px solid #117a8b; border-bottom: 0px solid #117a8b; border-left: 0px solid #117a8b; border-right: 0px solid #117a8b; border-top-left-radius: 15px; border-top-right-radius: 15px; border-bottom-left-radius: 15px; border-bottom-right-radius: 15px;" href="#load_next_page">Load Previous</a>
   </div>
   <ul class="products columns-3">
    <li class="store-product product type-product post-384 status-publish first instock product_cat-bags_luggage product_cat-lunchboxes product_tag-featured has-post-thumbnail taxable shipping-taxable purchasable product-type-simple berocket_lmp_first_on_page" data-url="http://localhost:8889/product-category/bags_luggage/">
     <a href="http://localhost:8889/wp_archive/bags_luggage/lunchboxes/15468/" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">
     <img width="300" height="300" src="http://localhost:8889/wp-content/uploads/2019/06/product-backpack-500-300x300.png" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail hoverZoomLink" alt="Test product" srcset="http://localhost:8889/wp-content/uploads/2019/06/product-backpack-500-300x300.png 300w, http://localhost:8889/wp-content/uploads/2019/06/product-backpack-500-100x100.png 100w, http://localhost:8889/wp-content/uploads/2019/06/product-backpack-500.png 500w" sizes="(max-width: 300px) 100vw, 300px">    
      <div class="product-text">
       <h2 class="woocommerce-loop-product__title">15468</h2><div>£150</div>    
      </div>
     </a>
    </li>
    <li class="store-product product type-product post-379 status-publish instock product_cat-bags_luggage product_cat-luggage product_tag-featured has-post-thumbnail taxable shipping-taxable purchasable product-type-simple">
     <a href="http://localhost:8889/wp_archive/bags_luggage/lunchboxes/15468/" class="woocommerce-LoopProduct-link woocommerce-loop-product__link"></a>
     <a href="http://localhost:8889/wp_archive/bags_luggage/luggage/testr/" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">
      <img width="300" height="300" src="http://localhost:8889/wp-content/uploads/2019/06/store-plate-300x300.png" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail hoverZoomLink" alt="test" srcset="http://localhost:8889/wp-content/uploads/2019/06/store-plate-300x300.png 300w, http://localhost:8889/wp-content/uploads/2019/06/store-plate-100x100.png 100w" sizes="(max-width: 300px) 100vw, 300px">  
      <div class="product-text">
       <h2 class="woocommerce-loop-product__title">testr</h2>
       <div>£34</div>   
      </div>
     </a>
    </li>
   </ul>
   <div class="lmp_load_more_button br_lmp_button_settings" style="display: none;">
    <a class="lmp_button btn btn-info" style="font-size: 22px;color: #ffffff;background-color: #17a2b8;padding-top:15px;padding-right:25px;padding-bottom:15px;padding-left:25px;margin-top:px;margin-right:px;margin-bottom:px;margin-left:px; border-top: 0px solid #117a8b; border-bottom: 0px solid #117a8b; border-left: 0px solid #117a8b; border-right: 0px solid #117a8b; border-top-left-radius: 15px; border-top-right-radius: 15px; border-bottom-left-radius: 15px; border-bottom-right-radius: 15px;" href="#load_next_page">Load More</a>
   </div>
   <a href="http://localhost:8889/wp_archive/bags_luggage/luggage/testr/" class="woocommerce-LoopProduct-link woocommerce-loop-product__link"></a>
  </div>
  <a href="http://localhost:8889/wp_archive/bags_luggage/luggage/testr/" class="woocommerce-LoopProduct-link woocommerce-loop-product__link"></a>
 </div>
 <a href="http://localhost:8889/wp_archive/bags_luggage/luggage/testr/" class="woocommerce-LoopProduct-link woocommerce-loop-product__link"></a>
</div>
<a href="http://localhost:8889/wp_archive/bags_luggage/luggage/testr/" class="woocommerce-LoopProduct-link woocommerce-loop-product__link"></a>
</div>
<a href="http://localhost:8889/wp_archive/bags_luggage/luggage/testr/" class="woocommerce-LoopProduct-link woocommerce-loop-product__link"></a>
</div>
<a href="http://localhost:8889/wp_archive/bags_luggage/luggage/testr/" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">
<div class="snow-break" style="bottom:-80px;"><!-- boop --></div>
</a>
</section>
<a href="http://localhost:8889/wp_archive/bags_luggage/luggage/testr/" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">

控制台没有错误,如何停止打印重复的http://localhost:8889/wp_archive/bags_luggage/luggage/testr/标签?

0 个答案:

没有答案