1

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' ); 
1
  • 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. Commented Sep 12, 2013 at 15:23

1 Answer 1

1

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.