0
votes

I have a problem showing my 2nd right sidebar only on woocommerce single-product page. It won't show it at all. Below is what I have done. What is wrong or what am I missing?

I added this to my woocommerce page, single-product.php file

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

I have added the sidebar to my wp-content > themes > theme > includes > sidebars.php file. It already had 4 sidebars (one right and three footer):

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>',
    ) );

I created a sidebar5.php page :

<?php if ( is_active_sidebar( 'sidebar-5' ) ){ ?>
    <div id="sidebar">
        <?php dynamic_sidebar( 'sidebar-5' ); ?>
    </div> <!-- end #sidebar -->
<?php } ?>
2
You included the sidebar file as sidebar2.php but you created the file as sidebar5.php...designtocode
typo - still does not show sidebarsloga

2 Answers

0
votes

i think you need to add the following code in functions.php instead of creating other file.

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>',
    ) );
0
votes

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>