如何将WooCommerce按分类布局应用到Dokan商家店铺商品列表?
问题:Dokan商家商品列表无法应用WooCommerce分类布局
我使用Astra主题搭配WordPress和Dokan多供应商插件,WooCommerce店铺页面的按分类布局(对应PHP代码如下)可正常显示,但该布局无法应用到Dokan商家的商品列表中。我找到了渲染商家商品的脚本,但不知如何调整。
WooCommerce店铺页面PHP代码
<?php add_action( 'woocommerce_no_products_found', 'bbloomer_show_4_products_per_category' ); function bbloomer_show_4_products_per_category() { $args = array( 'parent' => 0, 'hide_empty' => true, 'taxonomy' => 'product_cat', 'fields' => 'slugs', ); $categories = get_categories( $args ); foreach ( $categories as $category_slug ) { $term_object = get_term_by( 'slug', $category_slug , 'product_cat' ); echo '<hr><h2>' . $term_object->name . '</h2>'; echo do_shortcode( '[products limit="4" columns="4" category="' . $category_slug . '"]' ); echo '<p><a href="' . get_term_link( $category_slug, 'product_cat' ) . '">View all ' . $term_object->name . ' products →</a>'; } } ?>
Dokan商家商品渲染脚本
<?php do_action( "dokan_store_before_{$section_id}_product_section", $vendor ); ?> <div id="dokan_store_section_<?php echo esc_attr( $section_id ); ?>" class="dokan-store-product-section"> <h2 class="products-list-heading"><?php echo esc_html( $section_title ); ?></h2> <div class="seller-items"> <?php woocommerce_product_loop_start(); ?> <?php while ( $products->have_posts() ) : $products->the_post(); ?> <?php wc_get_template_part( 'content', 'product' ); ?> <?php endwhile; ?> <?php woocommerce_product_loop_end(); ?> <?php wp_reset_postdata(); ?> </div> </div> <?php do_action( "dokan_store_after_{$section_id}_product_section", $vendor ); ?>
内容的提问来源于stack exchange,提问作者tyrese humphreys
相关产品推荐
相关产品推荐

