Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to add a sidebar to woocommerce woocommerce_before_shop_loop hook. I'm using the following code in the functions.php file:

add_action( 'woocommerce_before_shop_loop', 'my_custom_before_shop_loop_sidebar', 1);
function my_custom_before_shop_loop_sidebar() {
      echo get_sidebar('my_custom_sidebar');
}

The problem that I got is that it displays the wordpress default sidebar instead of the sidebar with the my_custom_sidebar id.

is there a way to accomplish this? thanks!

Ah by the way, I'm registering the sidebar like this :

/**
 * Register sidebars
*/
function meir_widgets_init() {
    register_sidebar( array(
        'name' => 'My Custom Sidebar',
        'id' => 'my_custom_sidebar',
        'description' => 'Sidebar for top filters.',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '<div class="clear"></div></div></div></div>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3><div class="filter_box"><div class="filter_wrapper">',
    ) );
}
add_action( 'widgets_init', 'meir_widgets_init' );
share|improve this question
    
There is an add on called WooSidebars, maybe look into that. Other than that, I suspect your 'my_custom_sidebar' is not being registered properly. Additional code would help. –  Nathan Powell Sep 12 '13 at 15:23

1 Answer 1

up vote 0 down vote accepted

Well I actually figured it out. Leaving the code in case someones need it later:

// Add sidebar for shop loop header  
function my_custom_before_shop_loop_sidebar() {

dynamic_sidebar('shop-loop-header-sidebar');

}

add_action( 'woocommerce_before_shop_loop', 'my_custom_before_shop_loop_sidebar', 2);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.