简体   繁体   中英

How to Disable Wordpress Default Widget in one SideBar

I have developed a Premium theme, but as soon as theme is installed wordpress by default throw some of its widgets in Header Area.

The theme looks very ugly at it first appearance when it is virgin w/o all the theme settings.

Although those widgets can be deleted mannualy from the Widget area of Header, but initially the buyer of that theme wouldn't get a Good Notion.

I want to disable wordpress few default widgets in one particular side bar.

I tried various things and researched on various forums.

I got few solutions such as : WordPress widgets can be completely disabled, but that what I do not want.

Has any one faced the same challenge like me. Please advice.

Summary of The Question: I want to disable wordpress default widgets in only one particular sidebar/widget area.

Thanks!

register a custom area for your header

function theme_widgets_init() {
        register_sidebar(array(
            'name' => __('Header widget', 'theme'),
            'id' => 'sidebar-1',
            .............
            .............
        ));
    add_action('widgets_init', 'theme_widgets_init');

and output it in your header like that:

<?php dynamic_sidebar('sidebar-1'); ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM