我有一个子主题,它会更改父主题的页脚(小部件区域)。我复制了 footer.php 并将其更改为包含我在 child 的 functions.php 中注册/激活的新页脚
我使用 unregister_sidebar( ' ' );从父项中删除其他侧边栏的代码。
问题:父级定义的页脚小部件区域没有“id”,因此我无法使用注销代码定位它。父侧边栏代码如下
function web2feel_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'web2feel' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
));
register_sidebar(array(
'name' => 'Footer',
'before_widget' => '<div class="botwid col-xs-6 col-md-3 %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="bothead">',
'after_title' => '</h3>',
));
}
add_action( 'widgets_init', 'web2feel_widgets_init' );
我想从后端摆脱两者。我能够使用其“sidebar-1”ID 定位第一个。但不能针对对方。
我怎样才能做到这一点?
最佳答案
有趣的问题,而不是因为没有 ID 而取消注册,您是否尝试过像下面这样删除小部件操作?
// Unhook default functions
function unhook_theme_functions() {
remove_action('widgets_init','web2feel_widgets_init');
}
add_action('init','unhook_theme_functions');
关于php - 在没有 ID 的子主题中注销侧边栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29179280/