0

我只在 woocommerce 单品页面上显示我的第二个右侧边栏时遇到问题。它根本不会显示出来。以下是我所做的。有什么问题或我错过了什么?

我将此添加到我的 woocommerce 页面,single-product.php 文件

<?php
        /**
        * woocommerce_sidebar hook
        *
        * @hooked woocommerce_get_sidebar - 10
        */
        /* do_action('woocommerce_sidebar'); */ 
           include("sidebar5.php");
?>

我已将侧边栏添加到我的 wp-content > 主题 > 主题 > 包含 > sidebars.php 文件中。它已经有 4 个侧边栏(一个右侧和三个页脚):

register_sidebar( array(
        'name' => 'Sidebar Woo',
        'id' => 'sidebar-5',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div> <!-- end .widget -->',
        'before_title' => '<h4 class="widgettitle">',
        'after_title' => '</h4>',
    ) );

我创建了一个 sidebar5.php 页面:

<?php if ( is_active_sidebar( 'sidebar-5' ) ){ ?>
    <div id="sidebar">
        <?php dynamic_sidebar( 'sidebar-5' ); ?>
    </div> <!-- end #sidebar -->
<?php } ?>
4

2 回答 2

0

instead of using the separate sidebar5.php page I put the code directly in the woocommerce single-product.php and removed the include.

<?php
        /**
        * woocommerce_sidebar hook
        *
        * @hooked woocommerce_get_sidebar - 10
        */
        /* do_action('woocommerce_sidebar'); */ 
          // include("sidebar5.php");
?>
<?php if ( is_active_sidebar( 'sidebar-5' ) ) : ?>
    <div id="sidebar">
        <?php dynamic_sidebar( 'sidebar-5' ); ?>
    </div>
于 2013-07-16T16:31:49.583 回答
0

我认为您需要在 functions.php 中添加以下代码,而不是创建其他文件。

register_sidebar( array(
        'name' => 'Sidebar Woo',
        'id' => 'sidebar-5',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div> <!-- end .widget -->',
        'before_title' => '<h4 class="widgettitle">',
        'after_title' => '</h4>',
    ) );
于 2013-07-02T16:43:39.303 回答