php - 在没有 ID 的子主题中注销侧边栏

标签 php css wordpress parent-child

我有一个子主题,它会更改父主题的页脚(小部件区域)。我复制了 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/

相关文章:

php - NuSOAP 和内容类型

php - Paypal 。支付信息页面

javascript - 通过点击菜单打开和关闭不同的div

javascript - IE11 的非跳跃视差 - 但如何?

php - MySQL 包含来自另一个表的重复值

php - searchBar.resignFirstResponder() 导致 nil 值

javascript - 数据库结果延迟 25 分钟

html - 如何向包含表格的 DIV 添加滚动条?

javascript - 在没有 photoshop 的情况下为图像设置样式以使其看起来相同

php - 在Woocommerce中获取所有客户手机号