Resolving WordPress Widgets Snapping Shut
I came across a peculiar problem recently when setting up widgets for a WordPress site I was working on. In summary, I was registering sidebars and adding widgets when a scenario arose whereby I was unable add widgets.
I would drag and drop an available widget into the respective sidebar and it would snap shut, preventing me from making changes to it.
After a bit of debugging I found the cause to be in my themes functions.php file and the fact I had some whitespace in it. An example of this can be found below:
<?php // Some code here ?> <?php // Some more code here ?>
Once I’d removed the whitespace and ensured all the code was between a single set of PHP tags the widgets then began to act as expected.