这是我在woocommerce开发的网站。边栏不会仅显示在类别页面右侧的类别页面上。在产品页面上显示正常。
用于显示产品档案的模板,包括作为帖子类型档案的主店铺页面。
通过将此模板复制到yourtheme / woocommerce / archive-product.php来覆盖此模板
<?php
/**
* woocommerce_before_main_content hook
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
*/
do_action( 'woocommerce_before_main_content' );
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
?>
<?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
/**
* woocommerce_before_shop_loop hook
*
* @hooked woocommerce_result_count - 20
* @hooked woocommerce_catalog_ordering - 30
*/
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
/**
* woocommerce_after_shop_loop hook
*
* @hooked woocommerce_pagination - 10
*/
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
/**
* woocommerce_after_main_content hook
*
* @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
?>
<?php
/**
* woocommerce_sidebar hook
*
* @hooked woocommerce_get_sidebar - 10
*/
do_action( 'woocommerce_sidebar' );
?>
答案 0 :(得分:1)
问题是你的div元素结构。尝试对模板中涉及的每个div的开始和结束进行排序。标题到标题,内容到内容,侧边栏到侧边栏,页脚到页脚div元素。
答案 1 :(得分:1)
您使用的是Woocommerce主题,自定义构建还是其他主题?
我建议检查内容包装器是否仍然与其他页面相同。 Woocommerce想要使用自己的包装div。 例如。在大多数页面上,您可能有以下包装:
<div id="primary">
<!-- ... Main content of your site -->
</div><!-- #primary -->
Woocommerce可能会压倒一切:
<div id="container"><div id="content" role="main">
要将此副本wrapper-start.php
和wrapper-end.php
修复为yourtheme/woocommerce/global/
,请修复相应文件中的打开和关闭div。
另外,您可以查看loop-start.php
loop-end.php
和/loop/
或者您可以尝试解开包装并添加自己的包装:
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper_end', 10 );
add_action( 'woocommerce_before_main_content', 'add_content_inner_wrapp', 10, 1 );
add_action( 'woocommerce_after_main_content', 'close_content_inner_wrap', 10, 1 );
function add_content_inner_wrapp(){
?>
<div id="container">
<div id="content-inner">
<?php
}
function close_content_inner_wrap(){
?>
</div><!-- #content-inner-->
</div><!-- #container-->
<?php
}
希望有所帮助。