首页 文章

补充工具栏未显示在Shop Page Woocommerce,Wordpress中

提问于
浏览
2

我非常绝望地试图解决这个问题 . 我正在定制一个Wordpress Tisson Pro主题为WooCommerce准备好(它不是) . 我已经做了与“第三方/自定义/非WC主题兼容性”相关的建议,在我自己的儿童主题中做了这件事,还有100万件事......但侧边栏看起来仍然没有在商店页面加载!我检查了代码,看起来问题如下;

woocommerce.php

<?php get_header();
$sidebar = mfn_sidebar_classes();

?>
<!-- Content -->
<div id="Content">
    <div class="container">
        <!-- .content -->
        <?php
            //open div
            if( $sidebar ) echo '<div class="content">';
            //get woocommerce content
            woocommerce_content();
            if( $sidebar ){
                //close div
                echo '</div>';
            } else {
                echo '<div class="clearfix"></div>';
            }
        ?>
        <!-- Sidebar -->
        <?php
            if( $sidebar ){
                get_sidebar();
            }
        ?>

    </div>
</div>
<?php get_footer(); ?>

代码没有进入if($ sidebar),不知何故我无法弄明白为什么!我没有运气就尝试了一切 .

如果你能帮助我,我会非常感激:)

2 回答

  • 1

    从WooCommerce Third Party Theme Compatibility docs,你应该能够定义你的包装...就我所知,它看起来像 <div class="content"> . 如果在 functions.php 中使用这些包装器,那么您不需要 woocommerce.php .

    add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10);
    add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10);
    
    function my_theme_wrapper_start() {
      echo '<div class="content">';
    }
    
    function my_theme_wrapper_end() {
      echo '</div>';
      echo '<div class="clearfix"></div>';
    }
    
  • 0

    试试这个 ..

    # WOOCOMMERCE CONNECT
    remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
    remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
    add_action( 'woocommerce_before_main_content', '_woocommerce_output_content_wrapper', 10 ); 
    add_filter( 'woocommerce_show_page_title', 'no_title' );
    function no_title(){
        return false;
    }
    function _woocommerce_output_content_wrapper(){
        echo '<div class="content"><div class="entry-content">';
        genesis_do_breadcrumbs();
        echo '<h1 class="entry-title" itemprop="headline">';
        woocommerce_page_title();
        echo '</h1>';
    }
    

    >> MORE DETAILS HERE

    仅当默认挂钩未移除或重新定位到不同功能时,上述代码才有效 .

    我可以知道您当前的商店网址吗?在创世纪,有一个页面设置,您可以选择页面布局 . 您应该选择侧边栏内容或内容侧边栏 . 然后在小部件上,您的主要侧边栏必须至少包含一个小部件,以便您看到结果 . 创世纪和woocommerce结构的问题是不一样的 . 您需要做的就是用 <div class="content"><div class="entry-content"> 包装woocommerce HTML . 结构应该是这样的

    <div class="content">
        <div class="entry-content">
            <woocommerce HTML>
        </div>
    </div>
    <sidebar>sidebar</sidebar>
    

    如果对齐仍然不正确,则问题出在CSS代码上 . 第二个选项是覆盖你的woocommerce文件到你当前的主题,不需要在functions.php中使用钩子 . 希望这会帮助你 .

相关问题