dongshi3361 2015-03-21 04:34
浏览 48

取消注册子主题中没有id的侧边栏

I have a child theme which changes the parent theme's footer (widget area). I copied the footer.php and changed it to include a new footer i registered/ativated in the child's functions.php

I use the unregister_sidebar( ' ' ); code to remove other sidebars from the parent.

PROBLEM: The footer widget area that the parent defines has no 'id' so I can't target it with the unregister code. Parent side-bar codes is as follows

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

I want to get rid of both from the back-end. I was able to target the first with its 'sidebar-1' id. But can't target the other.

How can I accomplish this?

  • 写回答

1条回答 默认 最新

  • dtufl26404 2015-03-21 13:15
    关注

    Interesting question, rather then unregister both as one does not have an ID have you tried removing the widgets action like below?

    // Unhook default functions
    function unhook_theme_functions() {
        remove_action('widgets_init','web2feel_widgets_init');
    }
    add_action('init','unhook_theme_functions');
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度