我正在尝试在woocommerce-woocommerce\\u-before\\u-shop\\u-loop-hook中添加一个侧栏。我在函数中使用以下代码。php文件:
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\');
}
我遇到的问题是,它显示wordpress默认侧栏,而不是带有my\\u custom\\u侧栏id的侧栏。
有没有办法做到这一点?谢谢
啊,顺便说一下,我正在注册侧边栏,如下所示:
/**
* 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\' );