WP 5.1 Using code based on Codex Example Dashboard Widget

I mistakenly renamed 'example_number' option as 'number'. I then renamed it as 'example_number'. I also have some other options as checkboxes like 'stats' and 'lists'. Everything saves and works as expected.

I decided to list the options so I can determine what's there. Hence:

$widget_options = self::get_dashboard_widget_options('my_widget_example');
foreach ($widget_options as $key => $value) {
    echo "{$key}: {$value} <br />";


example_number: blah


stats: hide

lists: hide

Option 'number' is empty, unused, and it's hampering development. What's an easy way to remove just 'number' from the array entirely? Or is it just easier to deactivate the plugin, delete 'dashboard_widget_options' from table 'wp_options' in mysql and reactivate?

  • It's pretty easy to delete 'dashboard_widget_options' from table 'wp_options'. That made it easy to resume. However, I'm asking because I couldn't find a simple way to remove a specific widget option in the codex. I'll assume that there is no easy way to remove just one widget option from the array unless I hear back that WP has a method not mentioned in the codex. – Chris Mar 4 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.