我需要添加新的侧边栏,以便在整个店铺的不同页面上相应地使用它们。
我使用Woocommerce和我自己的店面儿童主题。
这是函数中的一个片段。子主题的php文件。
add_action( \'init\', \'init_storefront_child\' );
function init_storefront_child() {
// It seems Wordpress doesn\'t take into consideration the 2 lines below.
remove_action( \'widgets_init\', \'storefront_widgets_init\' ); // Not fired (or overrided by something)
add_action( \'widgets_init\', \'storefront_child_widgets_init\' ); // Not fired (or overrided by something)
}
function storefront_child_widgets_init() {
register_sidebar( array(
\'name\' => __( \'Blog Sidebar\' ),
\'id\' => \'blog\',
\'description\' => \'Sidebar displaying in blog.\',
\'before_widget\' => \'<aside id="%1$s" class="widget %2$s">\',
\'after_widget\' => \'</aside>\',
\'before_title\' => \'<h3 class="widget-title">\',
\'after_title\' => \'</h3>\',
) );
}
因此,“外观>小部件”菜单中的侧栏不会改变,并保持原来的状态。我试图直接在店面主题文件中更改代码,但这完全不是解决方案。
“widgets\\u init”钩子函数会发生什么。php的子主题?
提前谢谢。