
这是我在woocommerce开发的网站。侧边栏不会显示在类别页面的右侧,只显示在类别页面上。在产品页面上显示正常。
用于显示产品档案的模板,包括商店主页面,它是post类型的档案。
通过将其复制到您的主题/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' );
?>发布于 2015-02-26 22:22:36
问题出在您的div元素结构上。尝试对模板中涉及到的每个div的开头和结尾进行排序。header到header,content到content,侧栏到侧栏,footer到footer div元素。
发布于 2015-02-26 22:50:07
您是否在使用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/中查看loop-start.php和loop-end.php
或者,您可以尝试解开包装器并添加您自己的包装器:
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_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
}希望这能有所帮助。
https://stackoverflow.com/questions/28730891
复制相似问题