1

I've been desperately searching for help with this. I would really love to remove the sidebar only from my woocommerce shop base page. In the admin options for my theme there's a place to enable the sidebar on the product page but what you select there impacts not just the shop base page but all of the archive pages.

Within the archive-product.php file there's code that controls the layout based on if that button is enabled so I thought my best bet would be to use an if else statement to say if its the shop page, use the 'no-sidebar' class. This is what I came up with but it's not working. Any thoughts would be fantastic.

<?php if ( is_object( $shop_page) ) : ?>
<div id="default_products_page_container" class="no-sidebar">
<?php elseif (have_posts() ) : ?>
<div id"default_products_page_container" class="with-sidebar">  
4

5 に答える 5

1

function.phpファイルでアクションフックを使用したいショップページからサイドバーを削除するには -

    add_action('woocommerce_before_main_content', 'remove_sidebar' );
    function remove_sidebar()
    {
        if ( is_shop() ) { 
         remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10);
       }
    }

ここで WooCommerce アクションとフィルター フックを取得できます - https://docs.woothemes.com/wc-apidocs/hook-docs.html

于 2016-08-03T12:33:02.967 に答える
0

使用しているテーマを確認して、テンプレートからサイドバーのコードを削除してください。

于 2013-05-30T01:32:12.567 に答える