【发布时间】:2021-01-20 10:26:00
【问题描述】:
我在 wooommerce 中创建了自定义商店页面,并从 archive-product.php 中删除了所有代码,并添加了以下代码,它正在显示产品。
defined( 'ABSPATH' ) || exit;
get_header( 'shop' );
/**
* Hook: woocommerce_before_main_content.
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
* @hooked WC_Structured_Data::generate_website_data() - 30
*/
do_action( 'woocommerce_before_main_content' );
?>
<div class="container">
<div class="products">
<div class="row">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
wc_get_template_part( 'content', 'product' );
endwhile;
} else {
echo __( 'No products found' );
}
wp_reset_postdata();
?>
</div>
</div>
</div>
<?php
get_footer( 'shop' );
现在我将在哪里获得此 wc_get_template_part( 'content', 'product' ); 的代码,因为我必须更改结构
下面的截图是 woocommerce 模板。
【问题讨论】:
标签: wordpress woocommerce wordpress-theming hook-woocommerce