Widgets are stored in the wp_options
table ( assuming the database prefix is wp_
). You can retrieve the option, and remove the widgets manually:
// Get all the associated widgets
$sidebar_widgets = get_option ( 'sidebars_widgets' );
// Check this specific sidebar
if ( isset( $sidebar_widgets [ 'lateral-header-sidebar' ] ) ) {
unset ( $sidebar_widgets [ 'lateral-header-sidebar' ] );
// Update the option
update_option ( 'sidebars_widgets', $sidebar_widgets );
}
You can do this in your theme activation hook.
Related Posts:
- Get sidebar parameters (before_widget, before_title, etc.) from within a widget
- Add div class to only one widget
- More flexible sidebar and widget management
- WordPress widget new instance creates content duplicates
- duplicate sidebar
- Removing custom widget area WordPress 4.4 [closed]
- Insert Widget option into mark-up with register_sidebar
- Cannot save widgets in custom sidebars
- Can’t see widget areas in my customizer
- Widgets not activated alert after using get_sidebar()
- Can you target a widget_class in a register_sidebar?
- Copy Widget Settings because of changed IDs
- Add class to on sidebar widget
- Why is registering a sidebar for each page causing my sidebars to reset?
- activate custom sidebar widgets
- How to create sidebar from “scratch”?
- How to get sidebar widgets in leftsidebar template
- $before/after_widget/title not displaying anything
- Unique widget id in sidebar
- Programmatically add widgets to sidebars
- Loading scripts only if a particular shortcode or widget is present
- Give Editor Access To Sidebar
- Where is the content of widgets stored in mysql table
- Get number of widgets in sidebar
- Text Widget creates a
- Add the sidebar/widget editor to the post edit screen?
- Show Woocommerce minicart widget in checkout page sidebar? And, how to make this update secure by overriding widget?
- HowTo: Add Class to Sidebar Widget List-Items
- How to add author details in the post sidebar?
- Determining a Widget Instance and Sidebar Location?
- Randomize widgets displayed in my sidebar [duplicate]
- What is the use case for the “Class” parameter in register_sidebar?
- Add a select box to all widgets
- Registering Sidebars and Sidebar Widgets. Sidebar Widgets Not Displaying
- Hooking Into Widget Output Loop
- Call sidebar from a template
- Adding classes to dynamic sidebar
- Create variable from widget instance
- Save/update widget outside admin panel [closed]
- Widget area inside a widget
- WordPress: Apply filter/hook to a particular sidebar widgets?
- Why use dynamic_sidebar() conditionally?
- wordpress widget textbox in the sidebar
- WordPress Widget multiple use
- Contact Form in sidebar [closed]
- How to check if searchform.php is being included as widget?
- How to get sidebar’s content inside admin-ajax?
- Full width layout for custom post type pages
- How to “pair” two widgets side by side in one sidebar [closed]
- Dynamic Sidebars On Multiple Subpages
- Check which registered sidebar a widget is added to
- Disable widgets on specific posts
- WordPress widget/sidebar dividers?
- Display the id list of active widgets of same sidebar?
- How to remove a widget from the sidebar on specific page?
- Add individual tag to widget title in sidebar
- Toggle option in sidebar widgets
- Excluding specific widgets from default sidebar class
- Can WordPress Read Its Own RSS Feed?
- How to show different widgets on different pages in a user friendly way
- Show widget differently depending on if it’s in the sidebar or footer
- Trying to create dynamic widget area using post ID
- Programmatically add widgets to sidebars
- Programmatically add widgets to sidebars
- How to call widget by widget’s id?
- Show a widget as a sidebar fallback
- register_sidebar fails when using a include within functions.php
- How to pass a special CSS class into widget li
- Add a specific css to a widget
- Is there a simple way to have a new sidebar for each page?
- how to add the same Widget twice to a sidebar?
- Filter Text from sidebar widget?
- Save button is not working on custom widget
- My widget not printing before_widgets and after widgets
- Multiple rows of footer widget areas
- Output column number according to active sidebars
- Check if widget is inside sidebar with PHP
- New Widget are not showing
- How do I exclude portrait pictures from the nextgen gallery sidebar widget?
- How to customize wordpress sidebar widget
- Upgraded to 3.3, My Widgets Disappeared
- How to use register_sidebar’s ‘before_widget’ unique id generator into its other parameters like ‘before_title’?
- Need to delete the sidebar widget area and have the page a full page rather than just have a blank widget area
- After adding widget the style is messing up
- Siderbar implementation with collapsible bootstrap cards
- Before_widget won’t show up
- Reposition the widget sidebar in Appearance->Widgets
- Handling dozens of sidebars
- Does current page contain widget or sidebar
- widgets_init actions not fired from functions.php’s child theme
- Active Sidebar Conditional Question?
- Target logic based on Widget / Sidebar Name
- Paginate recent posts widget
- register_sidebar() will not wrap an element properly
- Automatically hide Widgets that would lengthen page
- How to exclude a widget from showing up on a page?
- How to hide sidebar widgets in all pages except Hompage?
- Keeping shortcode-generated widget and theme element in one line [closed]
- How to inject a virtual widget (i.e. without adding it to the database) to the sidebar
- How to tell if a dynamic sidebar is being displayed on page?