如何嵌套产品并更改 Woocommerce 中的显示?
How do I nest products & change the display in Woocommerce?
我正在尝试使用 Woocommerce 在 Wordpress 的商店中嵌套产品。本质上,我试图在我的 Woocommerce 网站内的商店内提供产品。 https://www.just-eat.co.uk/ is an example of a exactly what I'm trying to receive. This 是 Just-Eat.co.uk & [this][3] 上的商店图片,其中包含产品。所以我的问题是我怎样才能做到这一点?
HTML(存档-products.php):
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
get_header( 'shop' ); ?>
<link rel="stylesheet" type="text/css" href="style.css"/>
<?php
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
do_action( 'woocommerce_archive_description' );
?>
<?php if ( have_posts() ) : ?>
<?php
do_action( 'woocommerce_before_shop_loop' );
?>
<?php woocommerce_product_loop_start(); ?>
<?php woocommerce_product_subcategories(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php endwhile; // end of the loop. ?>
<?php woocommerce_product_loop_end(); ?>
<?php
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
do_action( 'woocommerce_after_main_content' );
?>
<?php
do_action( 'woocommerce_sidebar' );
?>
您可以创建 'Restaurants' 作为 woocommerce 类别并将其相应产品分配到这些类别中。
- 在 woocommerce > 设置 > 产品选项卡 > 显示中将 "Shop Page Display" 选项设置为 "Show categories & subcategories"。这样在商店页面上只会显示类别(餐厅)。
- 当点击任何类别(餐厅名称)类别页面时
(餐厅)页面将在其各自产品所在的位置打开
已列出。
此外,如果您愿意,您可以为每个产品添加标签以另一种分组方式。
希望对您有所帮助。
我正在尝试使用 Woocommerce 在 Wordpress 的商店中嵌套产品。本质上,我试图在我的 Woocommerce 网站内的商店内提供产品。 https://www.just-eat.co.uk/ is an example of a exactly what I'm trying to receive. This 是 Just-Eat.co.uk & [this][3] 上的商店图片,其中包含产品。所以我的问题是我怎样才能做到这一点?
HTML(存档-products.php):
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
get_header( 'shop' ); ?>
<link rel="stylesheet" type="text/css" href="style.css"/>
<?php
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
do_action( 'woocommerce_archive_description' );
?>
<?php if ( have_posts() ) : ?>
<?php
do_action( 'woocommerce_before_shop_loop' );
?>
<?php woocommerce_product_loop_start(); ?>
<?php woocommerce_product_subcategories(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php endwhile; // end of the loop. ?>
<?php woocommerce_product_loop_end(); ?>
<?php
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
do_action( 'woocommerce_after_main_content' );
?>
<?php
do_action( 'woocommerce_sidebar' );
?>
您可以创建 'Restaurants' 作为 woocommerce 类别并将其相应产品分配到这些类别中。
- 在 woocommerce > 设置 > 产品选项卡 > 显示中将 "Shop Page Display" 选项设置为 "Show categories & subcategories"。这样在商店页面上只会显示类别(餐厅)。
- 当点击任何类别(餐厅名称)类别页面时 (餐厅)页面将在其各自产品所在的位置打开 已列出。
此外,如果您愿意,您可以为每个产品添加标签以另一种分组方式。
希望对您有所帮助。