This has had me stumped for hours but I finally got to the bottom of it. I will do a more comprehensive article on this subject at a later date, but here is the issue and solution for those who come across this.
The issue
When dragging a widget into the widget area in the admin panel it successfully drags and seems to save but if you do a refresh of that page the widget has been removed from the widget area.
The solution
When declaring the widget ID and Widget name they need to have a relationship, the id needs to be the same as the name but lower case and spaces substituted for hypens, so below is a correct declaration for a widget area:
register_sidebar(array(
'id' => 'header-login',
'description' => __( 'The widget area for the logon form'),
'name' => 'Header Login',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
));
I hope this helps as it wasted 3 hours of my day 🙂
Thanks for the hard work, I must ask however, where do I put this, which file? Am I replacing other code or just adding this? Thanks and sorry, I’m a noob..
There are various places to call this function, it could be in your specific plugin function or could be in your functions.php file, in my case it was in my functions.php file. Hope this helps.