When I activate the theme for the first time on a clean WP install 6 widgets get automatically added to lateral-header-sidebar
http://prntscr/l9cx84
Am I registering them the wrong way or why are they added to this particular sidebar and not any other?
Any help is appreciated.
widgets
sidebar
register-sidebar
Share
Improve this question
asked Oct 23, 2018 at 9:32
BennBenn1,07311 gold badge1515 silver badges3232 bronze badges1
Your registration code looks fine to me. How's the rest of your theme code? Are there any other widget related functions that might hook into after_switch_theme for example? Something along these lines, stackoverflow/questions/11757461/… Or are there any plugins that might be the cause?
– Antti Koskinen
CommentedOct 25, 2018 at 10:52
Add a comment
|
1 Answer
1
Reset to default
1
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 );
}
after_switch_theme
for example? Something along these lines, stackoverflow/questions/11757461/… Or are there any plugins that might be the cause? – Antti Koskinen Commented Oct 25, 2018 at 10:52