我是wordpress和woocommerce开发部门的新手。我正在尝试为我的产品整合woocommerce,一切都很好。但当我点击product permalink查看产品详细信息或产品单页时,它会重定向到同一页。有趣的是,当我点击产品时,url改变了,但没有进入详细信息页面。
以下是页面链接-https://dev.shopvitalsleep.com/collections/all/
我在woocommerce内部使用循环。php与我的自定义设计页面。
下面是代码示例-
<div class="row justify-content-center equal-box">
<?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();
$product = wc_get_product($loop->post->ID);
?>
<div class="col-lg-6 mb-4">
<div class="product-content text-center">
<div class="product-images">
<a href="<?php the_permalink(); ?>" class="product-details-link">
<?php the_post_thumbnail(\'full\'); ?>
</a>
</div>
<div class="product-info">
<h4 class="product-title"><?php echo get_the_title(); ?></h4>
<div class="price">
<p>
<span class="reg-price">
<del>$<?php echo get_post_meta( get_the_ID(), \'_regular_price\', true ); ?></del>
</span>
<span class="sell-price">now $<?php echo get_post_meta( get_the_ID(), \'_sale_price\', true ); ?> USD</span>
</p>
</div>
</div>
</div>
<div class="row mt-auto product-content text-center mb-2">
<div class="col-6">
<a class="button style-blue view-detail-button" href="<?php the_permalink(); ?>">View Details</a>
</div>
<div class="col-6">
<div class="add-to-cart "><?php
echo sprintf( \'<a href="%s" data-quantity="1" class="%s" %s>%s</a>\',
esc_url( $product->add_to_cart_url() ),
esc_attr( implode( \' \', array_filter( array(
\'button\', \'product_type_\' . $product->get_type(),
$product->is_purchasable() && $product->is_in_stock() ? \'add_to_cart_button\' : \'\',
$product->supports( \'ajax_add_to_cart\' ) ? \'ajax_add_to_cart\' : \'\',
) ) ) ),
wc_implode_html_attributes( array(
\'data-product_id\' => $product->get_id(),
\'data-product_sku\' => $product->get_sku(),
\'aria-label\' => $product->add_to_cart_description(),
\'rel\' => \'nofollow\',
) ),
esc_html( $product->add_to_cart_text() )
);
?>
</div>
</div>
</div>
</div>
<?php
endwhile;
} else {
echo __( \'No products found\' );
}
wp_reset_postdata();
?>
</div>
文件夹结构:
../themes/theme-name/woocommerce.php
请帮我找出我犯错误的地方。