简体   繁体   English

内容下方的woocommerce侧栏

[英]woocommerce sidebar below content

I am using bootstrap with a Wordpress theme I working on with Woocommerce installed. 我正在使用带有Woocommerce的Wordpress主题的引导程序。 On the Shop page the container element is not wrapping the sidebar, even though the other pages (ie Checkout, Cart, My Account) are in a Bootstrap container class and display fine. 在“商店”页面上,即使其他页面(例如,“结帐”,“购物车”,“我的帐户”)位于Bootstrap容器类中并显示正常,容器元素也不会包装边栏。 However, the Shop page is also in a container and the sidebar is displaying below all the content. 但是,“商店”页面也位于容器中,并且侧栏显示在所有内容的下方。

Here is the code for the shop page 这是商店页面的代码

    get_header( 'shop' ); ?>

<?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' );
?>
<div class="container">
<div class="row">
    <div class="col-md-8">
    <?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>

        <h1 class="page-title"><?php woocommerce_page_title(); ?></h1>

    <?php endif; ?>

    <?php
        /**
         * woocommerce_archive_description hook.
         *
         * @hooked woocommerce_taxonomy_archive_description - 10
         * @hooked woocommerce_product_archive_description - 10
         */
        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' );
    ?>
    </div>
    <div class="col-md-4">      
    <?php
        /**
         * woocommerce_sidebar hook.
         *
         * @hooked woocommerce_get_sidebar - 10
         */
        do_action( 'woocommerce_sidebar' );
    ?>
    </div>
</div>
</div>

<?php get_footer( 'shop' ); ?>

The sidebar falling under the content div means that you have HTML markup errors; 侧栏位于内容div之下,表示您有HTML标记错误; that's usually a closing </div> or two that is missing at the bottom of the page. 通常是页面底部缺少的结束符</div>或两个。 Extra opening <div> 's can also cause the sidebar to drop. 额外打开<div>也会导致侧栏下降。

Count your opening <div> and closing </div> 's and match them up in all page templates and template part files used: header.php , the shop template, footer.php and any other included template files. 计算您的开始<div>和结束</div> ,并在所有使用的页面模板和模板零件文件中进行匹配: header.php ,shop模板, footer.php和任何其他包含的模板文件。

Or, view source on the page and match them up, find the errors and make corrections in the appropriate template file. 或者,在页面上查看源代码并进行匹配,找到错误并在相应的模板文件中进行更正。

Or, use the W3C Code Validation tool to find them https://validator.w3.org/ and other markup errors you may not know about, and then make the corrections in the template file. 或者,使用W3C代码验证工具找到它们https://validator.w3.org/和其他您可能不知道的标记错误,然后在模板文件中进行更正。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM